On linux you just need to put #!/usr/bin/env julia at the top of the file, run chmod +x filename and add it to the system path. I assume it’s similar for macs, but I have no idea for windows.
In your case you will also need to add the cli() function call to the file itself so that the file is a self-contained script.
Are you intending to provide this as a registered Julia package (via METADATA)? If so, that’s the key difference - I don’t expect Pkg.install or Pkg.build to do anything to my global environment, and I’d be TICKED if some package I installed started installing executables outside the environment or altering my path.
If this is intended to be installed via some other means, then you could do what homebrew does; namely, create a separate script and make that script download and chmod the file. Since PATH environments are widely different, there’s not a whole lot you can do about that except try to write things into /usr/local/ somewhere.
What I had in mind was that most of those changes would be checked into git and wouldn’t run in your build.jl. The only thing that would happen in build.jl is that you invite the user to add a given directory to their path.
I guess this means that, in general, any BinDeps-using package is going to be a no-go (or at least a bureaucratic hassle) on most HPCs that provide even a modicum of security.
This is pretty off-topic, but if the package provides a “from source” build option, that doesn’t need root, but I believe the system package manager takes precedence. You need to manually comment-out the provides(AptGet, ...) line in build.jl if you want to prevent the package from preferring the system package manager.
For *nix, I’d suggest either installation instructions that include “download, chmod +x, move to directory in path”, or a shell script that does this that gets executed by whatever package manager / distribution mechanism that is used to install the tool.
I’m not quite sure what problem you’re trying to solve here, then. At some point in order to use a CLI tool one needs an executable to be installed in a place that the user can run it. It sounded to me like you didn’t have that, which is what my previous comment attempted to address.
This problem isn’t unique to Julia; it’s part of the installation process for every downloaded executable ever.
If you could enumerate specifically what you’re trying to do, and what problems you’re running into, maybe we could help find a solution.
alias julz="julia -L ~/.julia/v0.6/Julz/src/functions/utils/cli.jl -e 'cli()' --"
In order to move from an alias to an executable, it needs to be distributed through something like apt-get or brew
I’m unclear on how to package a Julia package in a format that would get approved by either of those projects (e.g. brew) where the executable is just that alias in a bash script
Are there other projects that have made Julia executables?
How do people deal with the need for people to have Julia and do a Pkg.clone before the script can be run?
I’m aware this problem is not unique to Julia.
I just don’t know how to accomplish it in as few steps as possible (without reinventing 10 wheels)
In order to move from an alias to an executable, it needs to be distributed through something like apt-get or brew
Why do you need to do this at all? Is it easier for folks to type apt-get install julz-cli (or whatever you’re calling it, and then making sure you’ve got both apt and brew installers, and then that just handles folks who have ubuntu and osx with homebrew installed) than to type curl -L https://mysite.com/install_tool.sh | bash (where install_tool.sh does the lifting)?