Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Ganache Installation issues #2918

Closed
VarunSaiTeja opened this issue Apr 17, 2022 · 15 comments
Closed

Ganache Installation issues #2918

VarunSaiTeja opened this issue Apr 17, 2022 · 15 comments

Comments

@VarunSaiTeja
Copy link

VarunSaiTeja commented Apr 17, 2022

npm i ganache -g
--Getting following error, please help me how to resolve this issue?

npm WARN cleanup Failed to remove some directories [
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\varun\\AppData\\Roaming\\npm\\node_modules\\ganache\\node_modules',
npm WARN cleanup     [Error: EBUSY: resource busy or locked, rmdir 'C:\Users\varun\AppData\Roaming\npm\node_modules\ganache\node_modules\keccak'] {
npm WARN cleanup       errno: -4082,
npm WARN cleanup       code: 'EBUSY',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\varun\\AppData\\Roaming\\npm\\node_modules\\ganache\\node_modules\\keccak'
npm WARN cleanup     }
npm WARN cleanup   ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path C:\Users\varun\AppData\Roaming\npm\node_modules\ganache\node_modules\leveldown
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
npm ERR!   builder.cc
npm ERR! C:\Users\varun\AppData\Roaming\npm\node_modules\ganache\node_modules\leveldown\deps\leveldb\port-libuv\port_uv.h(42,10): fatal error C1083: Cannot open include file: 'uv.h': No such file or directory [C:\Users\varun\AppData\Roaming\npm\node_modules\ganache\node_modules\leveldown\deps\leveldb\leveldb.vcxproj]
npm ERR!   snappy-sinksource.cc
npm ERR!   snappy-stubs-internal.cc
npm ERR!   snappy.cc
npm ERR!   win_delay_load_hook.cc
npm ERR!   snappy.vcxproj -> C:\Users\varun\AppData\Roaming\npm\node_modules\ganache\node_modules\leveldown\build\Release\\snappy.lib
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.10.4 found at "C:\Users\varun\AppData\Local\Programs\Python\Python310\python.exe"
npm ERR! gyp info find VS using VS2022 (17.1.32407.343) found at:
npm ERR! gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\varun\AppData\Local\Programs\Python\Python310\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Users\\varun\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\varun\\AppData\\Roaming\\npm\\node_modules\\ganache\\node_modules\\leveldown\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\varun\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\varun\\AppData\\Local\\node-gyp\\Cache\\16.14.2\\include\\node\\common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\varun\\AppData\\Local\\node-gyp\\Cache\\16.14.2',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\varun\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\varun\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.14.2\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\varun\\AppData\\Roaming\\npm\\node_modules\\ganache\\node_modules\\leveldown',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'C:\\Users\\varun\\AppData\\Roaming\\npm\\node_modules\\ganache\\node_modules\\leveldown\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Users\varun\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:526:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Windows_NT 10.0.22000
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\varun\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\varun\AppData\Roaming\npm\node_modules\ganache\node_modules\leveldown
npm ERR! gyp ERR! node -v v16.14.2
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\varun\AppData\Local\npm-cache\_logs\2022-04-17T13_50_24_999Z-debug-0.log
@haltman-at
Copy link
Contributor

Hi @VarunSaiTeja, could we get more information about your environment so we can attempt to reproduce this? Thank you!

(Also worth noting, this issue appears to be related to #2535 and #2445.)

@merlox
Copy link

merlox commented May 7, 2022

I get the same error it's so annoying

@davidmurdoch
Copy link
Member

Can you try using npm 6 (the default version the ships with node 14)?

@ccornici
Copy link

ccornici commented May 9, 2022

Same error

PS C:\Users\CLX> npm install ganache --global
npm WARN cleanup Failed to remove some directories [
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\CLX\\AppData\\Roaming\\npm\\node_modules\\ganache\\node_modules',
npm WARN cleanup     [Error: EBUSY: resource busy or locked, rmdir 'C:\Users\CLX\AppData\Roaming\npm\node_modules\ganache\node_modules\keccak'] {
npm WARN cleanup       errno: -4082,
npm WARN cleanup       code: 'EBUSY',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\CLX\\AppData\\Roaming\\npm\\node_modules\\ganache\\node_modules\\keccak'
npm WARN cleanup     }
npm WARN cleanup   ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path C:\Users\CLX\AppData\Roaming\npm\node_modules\ganache\node_modules\leveldown
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
npm ERR!   builder.cc
npm ERR! C:\Users\CLX\AppData\Roaming\npm\node_modules\ganache\node_modules\leveldown\deps\leveldb\port-libuv\port_uv.h(42,10): fatal error C1083: Cannot open include file: 'uv.h': No such file or directory [C:\Users\CLX\AppData\Roaming\npm\node_modules\ganache\node_modules\leveldown\deps\leveldb\leveldb.vcxproj]
npm ERR!   snappy-sinksource.cc
npm ERR!   snappy-stubs-internal.cc
npm ERR!   snappy.cc
npm ERR!   win_delay_load_hook.cc
npm ERR!   snappy.vcxproj -> C:\Users\CLX\AppData\Roaming\npm\node_modules\ganache\node_modules\leveldown\build\Release\\snappy.lib
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.7.9 found at "C:\Users\CLX\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe"
npm ERR! gyp info find VS using VS2019 (16.11.32002.261) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\CLX\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\CLX\\AppData\\Roaming\\npm\\node_modules\\ganache\\node_modules\\leveldown\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\CLX\\AppData\\Local\\node-gyp\\Cache\\16.15.0\\include\\node\\common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\CLX\\AppData\\Local\\node-gyp\\Cache\\16.15.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\CLX\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.15.0\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\CLX\\AppData\\Roaming\\npm\\node_modules\\ganache\\node_modules\\leveldown',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'C:\\Users\\CLX\\AppData\\Roaming\\npm\\node_modules\\ganache\\node_modules\\leveldown\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19043
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\CLX\AppData\Roaming\npm\node_modules\ganache\node_modules\leveldown
npm ERR! gyp ERR! node -v v16.15.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok

@davidmurdoch
Copy link
Member

What is the result of running npm --version?

@ccornici
Copy link

ccornici commented May 9, 2022

$ npm --version
8.5.5

@davidmurdoch
Copy link
Member

Can you try using npm 6 (the default version the ships with node 14)?

@ccornici
Copy link

I don't have node 14. Is Genache only working with node 14?

@davidmurdoch
Copy link
Member

davidmurdoch commented May 10, 2022

No it works with node v12-16 (v18 support is coming in the next release). Npm can be a problem; the newer versions are very buggy.

You can also try reinstalling Node with Windows Build Tools checkbox enabled.

@ccornici
Copy link

This worked but....I'm not sure I'd call this a fix :)

@its-everdred
Copy link

@ccornici, agreed. Thanks for surfacing this, we'll make sure to fix it!

@SeanLuis
Copy link

With the version of node 14 it works perfectly. I had the same problem with version 16 of node on MacOS. On Windows I tried and it works perfectly with version 16 of node and npm 8, you just have to install the version of python 3.9 and Visual Studio Community Edition 2019, the latter only the development tools for desktop and Node.js.

@tenthirtyone
Copy link
Contributor

While investigating I am noticing the following packages on Node 14+ requiring node-gyp rebuild.

On a Windows 10 VM I can confirm without the additional windows build tools for node-gyp this is where the install bombs out. I believe some of the related issues corroborate

bufferutil
keccak
leveldown
secp256k1
utf-8-validate

Strangely, on node 16 & 18 I am noticing the prebuild package @trufflesuite/bigint-buffer also requiring node-gyp rebuild

--> npm info run @trufflesuite/[email protected] install node_modules/ganache/node_modules/@trufflesuite/bigint-buffer node-gyp rebuild
npm info run [email protected] install node_modules/ganache/node_modules/bufferutil node-gyp rebuild
npm info run [email protected] install node_modules/ganache/node_modules/keccak node-gyp rebuild
npm info run [email protected] install node_modules/ganache/node_modules/leveldown node-gyp rebuild
npm info run [email protected] install node_modules/ganache/node_modules/secp256k1 node-gyp rebuild
npm info run [email protected] install node_modules/ganache/node_modules/utf-8-validate node-gyp rebuild
--> npm info run @trufflesuite/[email protected] install { code: 0, signal: null }
npm timing build:run:install:node_modules/ganache/node_modules/@trufflesuite/bigint-buffer Completed in 663ms
npm info run [email protected] install { code: 0, signal: null }
npm timing build:run:install:node_modules/ganache/node_modules/bufferutil Completed in 739ms
npm info run [email protected] install { code: 0, signal: null }
npm timing build:run:install:node_modules/ganache/node_modules/utf-8-validate Completed in 713ms
npm info run [email protected] install { code: 0, signal: null }
npm timing build:run:install:node_modules/ganache/node_modules/secp256k1 Completed in 4443ms
npm info run [email protected] install { code: 0, signal: null }
npm timing build:run:install:node_modules/ganache/node_modules/keccak Completed in 4754ms
npm info run [email protected] install { code: 0, signal: null }
npm timing build:run:install:node_modules/ganache/node_modules/leveldown Completed in 19185ms

I am not yet familiar with prebuildify and the process but it seems straightforward. I am going to spend some time on Node 14 trying to mirror the same process with bigint-buffer for the bufferutil, keccak, etc packages.

My hunch is that we need to add additional targets for 16 & 18 and possibly add these packages to our prebuilds, which mostly likely will require a change in our prebuild process (either by adding these packages or perhaps the creation of a common package that exports the bundles? Something else? I haven't explored yet).

This hunch is mostly based on node 12/14 using npm 6, node 16 using npm 7, and node 18 using npm 8. I am presuming prebuildify targeting may be suspect here.

@tenthirtyone
Copy link
Contributor

I was able to get this running on Windows 10 running Node 16 by rebuilding the bigint-buffer package supplying specific targets for Node version.

Steps:

  1. I forked @trufflesuite/bigint-buffer here.
  2. I re-ran the prebuildify in node 16.9.1 for each platform while specifying targets in node 16 and 14
    prebuildify --napi --platform darwin --arch x64 --target 16.9.1 --target 14.18.2 --strip-bin
    prebuildify --napi --platform win32 --arch x64 --target 16.9.1 --target 14.18.2 --strip-bin
    prebuildify --napi --platform linux --arch x64 --target 16.9.1 --target 14.18.2 --strip-bin
  3. I rescoped and published this package to my npm here
  4. I forked Ganache, on the private-npm branch I replaced the @trufflesuite/bigint-buffer with @tenthirtyone/bigint-buffer
  5. I set an INFURA_KEY env var, reinstalled, and rebuilt ganache with the replaced bigint-buffer package.
  6. I published this version of ganache to a private npm repo here (I can invite collaborators if needed.
  7. I spun up a fresh Windows 10 VM in Virtual Box. Installed Node 16 without windows dev tools.
  8. From a PowerShell npm install ganache -g

Expected Results:
This will fail with a similar message to the install failures issues. Different messages are given depending on the user's machine. For a fresh install of windows, there is no python or visual studio installed. So node-gyp can possibly fail at different points GYPs attempt to do the build. For the fresh install, this will fail at trying to find python.

  1. npm login to my account so that I can install the private ganache repo I built above.
  2. npm install @tenthirtyone/ganache -g (You may have to use --force because Windows does not clean up AppData\Roaming on a failure)

Expected Results:
Installation will complete, but there is another step.

  1. On a fresh Windows 10 installation, the ganache command will fail with the following error:
ganache : File C:\Users\lol\AppData\Roaming\npm\ganache.ps1 cannot be loaded because running scripts is disabled on this system...
  1. Open PowerShell as administrator
  2. Run Get-ExecutionPolicy -List

ER:
Scope policies will list. Line 'LocalMachine' will show 'Undefined'

  1. In the admin terminal, run set-executionpolicy remotesigned, select 'A' for accept all, re-run Get-ExecutionPolicy -List

ER:
Scope policy for 'LocalMachine' will show 'RemoteSigned'

  1. Return to PowerShell that previously failed running ganache.
  2. Run ganache

ER: Ganache starts

Next Steps:
I am going to verify the targets. It may just have worked because I ran the prebuild commands from Node 16 and I may have handicapped node 12 because I did not specify targets for it. I also do not know how semver plays into targeting. So although lengthy, I am going to run a few more experiments on those before opening a PR to @trufflesuite/bigint-buffer with the new builds.

Call Outs:
I do not know the side effects, if any, that come from prebuilds. Like I don't know if there is some wonky edge-case in the internals. Id call it low risk/medium impact since ganache builds/runs

@davidmurdoch
Copy link
Member

This should be fixed by #3208 in the next release

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants