volta icon indicating copy to clipboard operation
volta copied to clipboard

`volta install` fetches x64 executable on arm64

Open fynnfluegge opened this issue 2 years ago • 7 comments

When I fetch a node runtime with volta on a terminal session with arch arm64 it fetches node with x64 executable.

What I did Make sure that my terminal session is on arm64:

Screenshot 2023-04-07 at 22 33 54

Fetching node 18: Screenshot 2023-04-07 at 22 34 37

Check current node version: Screenshot 2023-04-07 at 22 35 44

Check arch of current node version: Screenshot 2023-04-07 at 22 36 34

What I expect node -e 'console.log(process.arch)' should return arm64

Current workaround I have to use nvm for arm64 node executables

Volta Vserion 1.1.1

fynnfluegge avatar Apr 07 '23 20:04 fynnfluegge

Hi @fynnfluegge, that's very strange! Can you check the arch of the actual Volta executable? The version for Apple Silicon should try to fetch the ARM Node if it's available and only fall back to x64 if it can't find an appropriate ARM one (e.g. on older versions of Node that don't have an ARM build).

charlespierce avatar Apr 19 '23 18:04 charlespierce

Hi @charlespierce thanks maybe that's the point! My terminal starts by default with Rosetta emulator with x64. I installed Volta then which gave me x64 executable I think.

fynnfluegge avatar Apr 22 '23 10:04 fynnfluegge

lol

matti avatar Apr 04 '24 08:04 matti

@charlespierce I wonder if this is the correct behavior now with universal binary of volta@2 installed in native terminal (mac m1 arm64) where

$ file  /Users/ssukienn/.volta/bin/volta
/Users/ssukienn/.volta/bin/volta: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64]
/Users/ssukienn/.volta/bin/volta (for architecture x86_64):     Mach-O 64-bit executable x86_64
/Users/ssukienn/.volta/bin/volta (for architecture arm64):      Mach-O 64-bit executable arm64

$ file  /Users/ssukienn/.volta/bin/node 
/Users/ssukienn/.volta/bin/node: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64]
/Users/ssukienn/.volta/bin/node (for architecture x86_64):      Mach-O 64-bit executable x86_64
/Users/ssukienn/.volta/bin/node (for architecture arm64):       Mach-O 64-bit executable arm64

$ node -p process.arch                  
x64

I have some conditional logic that expects arm64 and node is run on native terminal (not rosetta) but arch in node process is x64, which I think is missleading.

For now I will need to fallback to volta <2. Wonder if this is volta problem or not?

ssukienn avatar Aug 20 '24 14:08 ssukienn

Hi @ssukienn, the universal binary shouldn't change the behavior, so that's odd! What version of Node is that running? Can you also share the output of file $(volta which node)? That should resolve the info about the actually installed Node binary.

I can't reproduce locally—also on an ARM64 Mac—Using the native terminal and the universal binary, I get the expected arm64 when running node -p process.arch

Is it possible that when Node was installed, you were in a Rosetta terminal? In that case it may launch the x64 portion of the universal binary, which would then only download the x64 node.

Separately, I wonder if we could improve our inventory to also consider architecture as well as version—that would alleviate the problem of installing a specific version with the "wrong" architecture, because the next time Volta was run with a different one, it would see that the matching architecture wasn't available and would then fetch the appropriate one.

charlespierce avatar Aug 20 '24 16:08 charlespierce

Hi, ye I just discovered I entered some workload which works in node14... So it was that as there are no official binaries for arm. Sorry for the fuss and thanks for the help!

ssukienn avatar Aug 20 '24 16:08 ssukienn

Ah ha, yeah that would do it! No worries, I still think it might make sense at some point in the future to include the architecture in the inventory check.

charlespierce avatar Aug 20 '24 17:08 charlespierce