Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: EACCES: permission denied, open '/root/.config/truffle/config.json'

Can't correct the EACCESS issue from trying to install truffle.

Yes I had installed initially npm via sudo and not nvm but that was corrected -unless who knows what- as per web.

This path did not actually exist so I created it as per a git issue:

/root/.config/truffle/

[root@home config]# ls -la |grep truffle
drwxrwxr-x. 2 root root   6 Jul 14 17:08 truffle

[user@home ~]$ nvm --version
0.34.0

$ npm -v
6.9.0

Assigned full permissions to node_modules:

ll|grep node
drwxrwxrwx. 31 user user 4096 Jul 14 16:58 node_modules

I tried a suggestion from this link:Permission denied when installing npm module.

A user in Ethereum SE has this issue on Ubuntu issue.

Explored the following link and gave full permissions to package-lock in case that was the issue npm notice created a lockfile as package-lock.json. You should commit this file

Tried forcing clear npm cache.

This github user apparently solved it by using sudo: truffle compile error (EACCES: permission denied) on V5 w/ Linux #1212

Install was also attempted as root.

$ sudo npm install -g truffle
/usr/local/lib/nodejs/node-v10.16.0-linux-x64/bin/truffle ->/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/cli.bundled.js

> [email protected] postinstall /usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle
> node ./scripts/postinstall.js

Error: EACCES: permission denied, open '/root/.config/truffle/config.json'
You don't have access to this file.

at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:343:35)
at Configstore.get all [as all] (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/~/configstore/index.js:31:1)
at new Configstore (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/~/configstore/index.js:25:31)
at Function.Config.getUserConfig (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/packages/truffle-config/index.js:395:1)
at Object.<anonymous> (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/mnemonics/mnemonic.js:11:1)
at __webpack_require__ (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/webpack/bootstrap fa1fcd3fc6c4fef3eaf9:19:1)
at Object.command.command (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/commands/develop.js:2:22)
at __webpack_require__ (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/webpack/bootstrap fa1fcd3fc6c4fef3eaf9:19:1)
at Object.module.exports.$schema (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/commands/index.js:9:12)
at __webpack_require__ (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/webpack/bootstrap fa1fcd3fc6c4fef3eaf9:19:1)
at Object.<anonymous> (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/packages/truffle-core/cli.js:33:29)
at __webpack_require__ (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/webpack/bootstrap fa1fcd3fc6c4fef3eaf9:19:1)
at /usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/webpack/bootstrap fa1fcd3fc6c4fef3eaf9:65:1
at Object.<anonymous> (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/cli.bundled.js:71:10)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
Error: Error while attempting to download and cache solc 0.5.8: Command failed: node ./build/cli.bundled.js obtain --solc=0.5.8
Error: EACCES: permission denied, open '/root/.config/truffle/config.json'
You don't have access to this file.

at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:343:35)
at Configstore.get all [as all] (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/~/configstore/index.js:31:1)
at new Configstore (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/~/configstore/index.js:25:31)
at Function.Config.getUserConfig (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/packages/truffle-config/index.js:395:1)
at Object.<anonymous> (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/mnemonics/mnemonic.js:11:1)
at __webpack_require__ (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/webpack/bootstrap fa1fcd3fc6c4fef3eaf9:19:1)
at Object.command.command (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/commands/develop.js:2:22)
at __webpack_require__ (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/webpack/bootstrap fa1fcd3fc6c4fef3eaf9:19:1)
at Object.module.exports.$schema (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/packages/truffle-core/lib/commands/index.js:9:12)
at __webpack_require__ (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/webpack/bootstrap fa1fcd3fc6c4fef3eaf9:19:1)
at Object.<anonymous> (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/packages/truffle-core/cli.js:33:29)
at __webpack_require__ (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/webpack/bootstrap fa1fcd3fc6c4fef3eaf9:19:1)
at /usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/webpack:/webpack/bootstrap fa1fcd3fc6c4fef3eaf9:65:1
at Object.<anonymous> (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/build/cli.bundled.js:71:10)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)

at postinstallObtain (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/scripts/postinstall.js:13:11)
at Object.<anonymous> (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/truffle/scripts/postinstall.js:20:3)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
+ [email protected]
updated 1 package in 5.873s

A different attempt based on cypress issue

$ sudo npm install --unsafe-perm=true --allow-root truffle
path.js:1077
    path = process.cwd();
                   ^

Error: ENOENT: no such file or directory, uv_cwd
at Object.resolve (path.js:1077:24)
at Function.Module._resolveLookupPaths (internal/modules/cjs/loader.js:534:17)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:629:20)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at /usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/local/lib/nodejs/node-v10.16.0-linux-x64/lib/node_modules/npm/bin/npm-cli.js:152:3)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
like image 995
DRP Avatar asked Jul 14 '19 21:07

DRP


1 Answers

I was having this problem with not just truffle but other modules as well. For me at least the other solutions listed in this thread worked but they had the side effect that I could only run truffle as super user. I know it may be a bit reckless but my solution was to change ownership of all files in the .config directory to my user. To accomplish this I did the following:

sudo chown myUsername:myUsername -R ~/.config

If you wanted to be a bit more careful about this you could alternatively run

sudo chown myUsername:myUsername ~/.config

sudo chown myUsername:myUsername ~/.config/truffle

sudo chown myUsername:myUsername ~/.config/truffle/config.json

After doing this I was able to run sudo npm i -g truffle. This was a quick fix to all the problems I had previously I hope it works for you!

like image 55
JegHeterSatoshi Avatar answered Sep 22 '22 18:09

JegHeterSatoshi