On 25 March 2015 at 18:13, Ignacio Burgueño <iburgu...@gmail.com> wrote: > Hi! > > I'd like to install rocks only if they are not already installed. I'd like > to avoid calling luarocks install <each_rock> since it will try to download > and build the rock, each time. > Is there something like a flag to instal, like, --skip if the rock is > already there? > > I could do: luarocks show <the rock> || luarocks install <the rock> > but wanted to check if there was a better way.
There is no better way... yet. The suggestion of adding a --skip flag seems the least intrusive way to do what you want, but I think it makes the logic kind of backwards (ie, the safer and more useful behavior in a flag and the more destructive enabled one by default). If the rock is already there and no version is given, or if a version is given and the same version is already installed, bailing out should probably be the default behavior, even. We have some design options, see below: (commands that don't hit the network are marked "[no network op]") Option a: add an 'upgrade' command. (Cue people asking for `upgrade --all` in 3...2...1...) $ luarocks show foo --mversion 1.0-1 [no network op] $ luarocks install foo Rock 'foo' is already installed. [no network op] $ luarocks upgrade foo <checks latest version in the network...> <Installing foo 2.0...> $ luarocks upgrade foo <checks latest version in the network...> Rock 'foo' version 2.0-1 is already installed. $ luarocks install foo 2.0 Rock 'foo' is already at version 2.0-1. [no network op] $ luarocks install foo 2.0 --force <installing foo 2.0 on top of same version...> Option b: same as above, but with '--upgrade' flag instead of new command. $ luarocks show foo --mversion 1.0-1 [no network op] $ luarocks install foo Rock 'foo' is already installed. [no network op] $ luarocks install foo --upgrade <checks latest version in the network...> <Installing foo 2.0...> $ luarocks install foo --upgrade <checks latest version in the network...> Rock 'foo' version 2.0-1 is already installed. $ luarocks install foo 2.0 Rock 'foo' is already at version 2.0-1. [no network op] $ luarocks install foo 2.0 --force <installing foo 2.0 on top of same version...> Option c: try to upgrade by default (plain `install` does what `install --upgrade` in Option b does). Simpler, but now there's no way to "install only if not present" without hitting the network. $ luarocks show foo --mversion 1.0-1 [no network op] $ luarocks install foo <checks latest version in the network...> <Installing foo 2.0...> $ luarocks install foo <checks latest version in the network...> Rock 'foo' version 2.0.-1 is already installed. $ luarocks install foo 2.0 Rock 'foo' is already at version 2.0-1. [no network op] $ luarocks install foo 2.0 --force <installing foo 2.0 on top of same version...> Option d: variant of the above, but imply "force" when given a version. $ luarocks show foo --mversion 1.0-1 [no network op] $ luarocks install foo <checks latest version in the network...> <Installing foo 2.0...> $ luarocks install foo <checks latest version in the network...> Rock 'foo' version 2.0.-1 is already installed. $ luarocks install foo 2.0 <installing foo 2.0 on top of same version...> For reference, the current behavior is: $ luarocks show foo --mversion 1.0-1 [no network op] $ luarocks install foo <checks latest version in the network...> <Installing foo 2.0...> $ luarocks install foo <checks latest version in the network...> <installing foo 2.0 on top of same version...> $ luarocks install foo 2.0 <installing foo 2.0 on top of same version...> Apart from potentially breaking some command-line compatibility (which is a concern), any of the four options above seem better behaviors than the current one. Opinions on which one is best are welcome. Please be more detailed than "+1 for option x": * Do we care about minimizing network access? * Is it more important than changing the default behavior? * User expectations: how do other PMs work in this regard? * What else am I missing? Pull requests implementing your favorite option go a long way towards lobbying for it too. :) -- Hisham ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Luarocks-developers mailing list Luarocks-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/luarocks-developers