Hi,
I just upgraded volta from version 1.0.0 to version 1.0.1 using homebrew. Right after the update, I had to run volta setup again (which I already did for version 1.0.0) to have node and yarn being sourced in my path. Before running, volta setup I couldn't access to the toolchain binaries. It seems that an upgrade via homebrew is resetting the path. I don't know if it's intentional or a bug but I wanted to report nonetheless.
System information:
Hi @olivier-martin-sf, thanks for reporting this! I suspect it's related to how Homebrew installs the different versions, but I'm not super familiar with the specifics of that formula. I'll take a look and see if there's a way we can get it to re-target the symlinks when upgrading.
Thank you @charlespierce, I am not familiar either but I will try to look into it on my side as well, hopefully I will come up with some insights
Since toolchain binaries are just symbolic links to <brew-prefix>/Cellar/volta/<volta-version>/bin/volta-shim, they can be broken if brew upgrade volta removes old versions of installed volta.
% brew --version
Homebrew 3.0.1-10-g0d36d54
Homebrew/homebrew-core (git revision 8857a2; last commit 2021-02-11)
Homebrew/homebrew-cask (git revision bed9c2; last commit 2021-02-11)
% brew --prefix
/opt/brew
% ls -la ~/.volta/bin/node
lrwxr-xr-x 1 uasi staff 43 2 12 01:14 /Users/uasi/.volta/bin/node -> /opt/brew/Cellar/volta/1.0.1/bin/volta-shim
It might be a good idea to add a post-install hook that runs volta setup. IMO less intrusive is better, something like volta setup --only-update-existing-toolchain.
diff --git a/Formula/volta.rb b/Formula/volta.rb
index 86cdd53971..55b08185e1 100644
--- a/Formula/volta.rb
+++ b/Formula/volta.rb
@@ -23,6 +23,10 @@ class Volta < Formula
system "cargo", "install", *std_cargo_args
end
+ def post_install
+ system "#{bin}/volta", "setup"
+ end
+
test do
system "#{bin}/volta", "install", "[email protected]"
node = shell_output("#{bin}/volta which node").chomp
That makes sense @uasi, and thanks for looking into the kind of change we would need. I agree we want to make it as unobtrusive as possible. The best bet (that I can see) would be to add "regenerate shim" behavior (which we already do during volta setup) directly to the volta-migrate binary. Then we can call that directly. It also would mean that any migration happens immediately when a new version is installed, instead of later on when it is invoked.
Most helpful comment
Hi @olivier-martin-sf, thanks for reporting this! I suspect it's related to how Homebrew installs the different versions, but I'm not super familiar with the specifics of that formula. I'll take a look and see if there's a way we can get it to re-target the symlinks when upgrading.