Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tooling] Installing genkit-cli using pnpm run setup can fail because of permissions problems #1850

Closed
yesudeep opened this issue Feb 5, 2025 · 4 comments · Fixed by #1879
Assignees
Labels
bug Something isn't working tooling
Milestone

Comments

@yesudeep
Copy link
Contributor

yesudeep commented Feb 5, 2025

Describe the bug
When running pnpm run setup, the npm link stage can fail to create symlinks if npm isn't run as root. It's likely not a good idea to run npm as root.

> genkit@ link-genkit-cli /home/yesudeep/code/github.com/firebase/genkit
> cd genkit-tools/cli && npm link

npm error code EACCES
npm error syscall mkdir
npm error path /usr/local/lib/node_modules
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'
npm error     at async mkdir (node:internal/fs/promises:857:10)
npm error     at async #extractOrLink (/usr/lib/node_modules_22/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:811:5)
npm error     at async /usr/lib/node_modules_22/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:715:7
npm error     at async Promise.allSettled (index 0)
npm error     at async [reifyPackages] (/usr/lib/node_modules_22/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:325:11)
npm error     at async Arborist.reify (/usr/lib/node_modules_22/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:142:5)
npm error     at async Link.linkPkg (/usr/lib/node_modules_22/npm/lib/commands/link.js:147:5)
npm error     at async Npm.exec (/usr/lib/node_modules_22/npm/lib/npm.js:207:9)
npm error     at async module.exports (/usr/lib/node_modules_22/npm/lib/cli/entry.js:74:5) {
npm error   errno: -13,
npm error   code: 'EACCES',
npm error   syscall: 'mkdir',
npm error   path: '/usr/local/lib/node_modules'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It is likely you do not have the permissions to access this file as the current user
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.
npm error A complete log of this run can be found in: /home/yesudeep/.npm/_logs/2025-02-05T04_54_52_317Z-debug-0.log
 ELIFECYCLE  Command failed with exit code 243.
ERROR: "link-genkit-cli" exited with 243.
 ELIFECYCLE  Command failed with exit code 1.

To Reproduce

  1. Run pnpm install and pnpm run setup on Fedora Linux 41.

Expected behavior
The repository version of genkit CLI should be usable without having to modify system files.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Fedora Linux 41
  • Browser Google Chrome
  • Version 41

Additional context

  1. A potential workaround would be to have a script wrapping the genkit CLI so the npm link stage is not required.
@yesudeep yesudeep added bug Something isn't working tooling labels Feb 5, 2025
@yesudeep yesudeep self-assigned this Feb 5, 2025
@yesudeep yesudeep added this to the py-0.1.0 milestone Feb 5, 2025
yesudeep added a commit that referenced this issue Feb 5, 2025
…al version of genkit cli #1850

ISSUE: #1850

CHANGELOG:
- [ ] Add a convenience wrapper script that does not require `npm
  link`ing the genkit CLI thereby avoiding permission problems
  faced on certain operating systems.
yesudeep added a commit that referenced this issue Feb 5, 2025
…al version of genkit cli #1850

RATIONALE:

On some systems, the `npm link` step in `pnpm run setup` fails to
execute owing to a lack of permissions and elevated privileges
are not available. Therefore, this wrapper script is a convenience
feature to allow using the repo-local version of the genkit cli
without having to symlink it into system directories.

ISSUE: #1850

CHANGELOG:
- [ ] Add a convenience wrapper script that does not require `npm
  link`ing the genkit CLI thereby avoiding permission problems
  faced on certain operating systems.
@tonybaroneee
Copy link
Collaborator

tonybaroneee commented Feb 5, 2025

I'd look into using nvm, or something similar to manage a node installation that is outside of /usr/local/lib where you are lacking permissions. For your machine, this issue would not be unique to genkit.

@yesudeep
Copy link
Contributor Author

yesudeep commented Feb 6, 2025

Unfortunately, even after setting up nvm, for some reason the npm link subcommand doesn't appear to symlink the repo-local version of the genkit CLI and we need a way to run the repo-local version of the genkit CLI. The wrapper script makes it convenient for our eng team to do this. I'll move this to the py/bin/genkit directory for now and will re-evaluate this a little later (post dev cleanup) to clean this script up when we figure out why npm link isn't doing what we're expecting it to on our machines.

yesudeep added a commit that referenced this issue Feb 6, 2025
ISSUE: #1850

CHANGELOG:
- [ ] Automatically add license header to a yaml file.
- [ ] Update the setup script to include nvm and update
      the version of go on some machines with older operating
      systems to unblock them.
- [ ] Add a `py/bin/genkit` wrapper script that allows
      running the repo-local version of genkit for situations
      when `npm link` doesn't work (even with nvm it doesn't
      on any of my machines).
@yesudeep yesudeep removed this from Genkit Backlog Feb 6, 2025
@yesudeep yesudeep linked a pull request Feb 6, 2025 that will close this issue
5 tasks
@MichaelDoyle
Copy link
Member

MichaelDoyle commented Feb 6, 2025

What do you get when you do which genkit in your terminal? Do you have genkit installed (globally) perhaps from following customer onboarding docs somewhere? Try removing it, OR make sure nvm is set earlier on your $PATH.

Should get something clean like this:

michaeldoyle-mac:~ michaeldoyle$
michaeldoyle-mac:~ michaeldoyle$ which genkit
/Users/michaeldoyle/.nvm/versions/node/v22.13.1/bin/genkit
michaeldoyle-mac:~ michaeldoyle$ genkit --version
1.0.0-rc.17

yesudeep added a commit that referenced this issue Feb 7, 2025
ISSUE: #1850

CHANGELOG:
- [ ] Automatically add license header to a yaml file.
- [ ] Update the setup script to include nvm and update
      the version of go on some machines with older operating
      systems to unblock them.
@yesudeep
Copy link
Contributor Author

yesudeep commented Feb 7, 2025

@MichaelDoyle I had to remove a previous global installation of genkit, remove pnpm, add nvm, install pnpm and then run the instructions from the docs for it to work. Closing this bug. Thank you!

@yesudeep yesudeep closed this as completed Feb 7, 2025
yesudeep added a commit that referenced this issue Feb 7, 2025
ISSUE: #1850

CHANGELOG:
- [ ] Automatically add license header to a yaml file.
- [ ] Update the setup script to include nvm and update
      the version of go on some machines with older operating
      systems to unblock them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment