Making mcp-scholarly Compatible with Linux/Ubuntu: Permission Denied Error
Users of the mcp-scholarly project may encounter an EACCES: permission denied error when running the software on Linux/Ubuntu systems. This error typically occurs during the installation or configuration phase, specifically when the application attempts to create a directory in the user's home directory.
The error message often looks like this:
node:fs:1371
const result = binding.mkdir(
^
Error: EACCES: permission denied, mkdir '/home/runner/.config/Claude'
at Object.mkdirSync (node:fs:1371:26)
at r.writeConfig (/home/ben/.npm/_npx/2d0620bb1d41b604/node_modules/@smithery/cli/dist/index.js:88:12790)
at r.installServer (/home/ben/.npm/_npx/2d0620bb1d41b604/node_modules/@smithery/cli/dist/index.js:88:13289)
at Fi.installServer (/home/ben/.npm/_npx/2d0620bb1d41b604/node_modules/@smithery/cli/dist/index.js:88:17808)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async dP (/home/ben/.npm/_npx/2d0620bb1d41b604/node_modules/@smithery/cli/dist/index.js:95:488)
at async nSe (/home/ben/.npm/_npx/2d0620bb1d41b604/node_modules/@smithery/cli/dist/index.js:113:2649) {
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/home/runner/.config/Claude'
}
Node.js v20.18.0
Root Cause: Insufficient Permissions
The root cause of this issue is typically insufficient permissions for the user running the mcp-scholarly application to create directories and files within their own home directory, specifically within the .config directory. This can happen due to various reasons, including incorrect file ownership or restrictive permissions set on the .config directory or its parent directories.
Solution: Adjusting Permissions
The solution involves granting the user the necessary permissions to create the required directory. Here are a few approaches:
- Changing Ownership: You can change the ownership of the
.configdirectory (or its parent) to the current user. Use thechowncommand: - Granting Write Permissions: Alternatively, you can grant write permissions to the user on the
.configdirectory using thechmodcommand: - Creating the Directory Manually: You can attempt to create the directory manually before running the
mcp-scholarlyapplication. This can sometimes circumvent permission issues if the parent directory has correct permissions.
sudo chown -R $USER:$USER ~/.config
This command recursively (-R) changes the owner and group of the .config directory and all its contents to the current user ($USER).
chmod +w ~/.config
This command adds write permissions (+w) to the .config directory for the user.
mkdir -p ~/.config/Claude
The -p flag ensures that parent directories are created if they don't exist.
Important Considerations and Tips
- Running as Root: While it might seem tempting to run the application with
sudo, it's generally discouraged. Running applications as root can introduce security vulnerabilities. It's better to adjust permissions correctly for the user. - Check Parent Directory Permissions: Ensure that the parent directories of
.config(e.g.,/home/runneror/home/benin the error message) also have appropriate permissions. The user needs execute permissions on these directories to be able to navigate into them. - NPM Global Packages and Permissions: If you installed
mcp-scholarlyor its dependencies globally using npm, you may encounter more complex permission issues. Consider using a Node version manager likenvmornto manage your Node.js versions and avoid global installations, which can often lead to permission problems. - Configuration Options: Check if
mcp-scholarlyprovides configuration options to specify a different directory for storing configuration files. If so, you can choose a location where the user has write access.
By addressing the permission issues, you should be able to successfully run mcp-scholarly on your Linux/Ubuntu system.