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

netlify lm:setup crashes #514

Closed
ehmicky opened this issue Sep 6, 2019 · 20 comments · Fixed by #1489
Closed

netlify lm:setup crashes #514

ehmicky opened this issue Sep 6, 2019 · 20 comments · Fixed by #1489
Assignees
Labels
type: bug code to address defects in shipped code

Comments

@ehmicky
Copy link
Contributor

ehmicky commented Sep 6, 2019

- Do you want to request a feature or report a bug?
Bug

- What is the current behavior?
netlify lm:setup crashes.

- If the current behavior is a bug, please provide the steps to reproduce.
I ran the following commands in order:

  • apt-get install git-lfs
  • git lfs version
  • netlify plugins:install netlify-lm-plugin
  • netlify lm:install
  • netlify lm:setup

All commands worked except the last one which shows:

Logging into your Netlify account...
Opening https://app.netlify.com/authorize?response_type=ticket&ticket=xxxxxx
---------------------------
Error: Unable to open browser automatically
spawn /home/ether/.local/share/netlify-cli/node_modules/netlify-lm-plugin/node_modules/@netlify/cli-utils/node_modules/cli-ux/lib/xdg-open ENOENT

Please open your browser & open the URL below to login:
https://app.netlify.com/authorize?response_type=ticket&ticket=xxxxxx
---------------------------
TypeError: Cannot read property 'slug' of undefined
    at LmSetup.authenticate (~/.local/share/netlify-cli/node_modules/netlify-lm-plugin/node_modules/@netlify/cli-utils/src/index.js:116:21)
    at async LmSetup.run (~/.local/share/netlify-cli/node_modules/netlify-lm-plugin/lib/commands/lm/setup.js:24:29)
    at async LmSetup._run (~/.local/share/netlify-cli/node_modules/netlify-lm-plugin/node_modules/@netlify/cli-utils/node_modules/@oclif/command/lib/command.js:34:20)
    at async Config.runCommand (~/.nvm/versions/node/v12.10.0/lib/node_modules/netlify-cli/node_modules/@oclif/config/lib/config.js:151:9)
    at async Main.run (~/.nvm/versions/node/v12.10.0/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/main.js:21:9)
    at async Main._run (~/.nvm/versions/node/v12.10.0/lib/node_modules/netlify-cli/node_modules/@oclif/command/lib/command.js:44:20)

- What is the expected behavior?
netlify lm:setup should not crash

- Local Environment Information
Paste the results of netlify status --verbose here

──────────────────────┐
 Current Netlify User │
──────────────────────┘
Name:  ehmicky
Email: [edited]
Teams: 
  ehmicky's team: Owner Collaborator Controller

────────────────────┐
 Environment Info   │
────────────────────┘

  System:
    OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
  Binaries:
    Node: 12.10.0 - ~/.nvm/versions/node/v12.10.0/bin/node
    npm: 6.11.3 - ~/.nvm/versions/node/v12.10.0/bin/npm
  Browsers:
    Chrome: 76.0.3809.132
    Firefox: 69.0

────────────────────┐
 Netlify Site Info  │
────────────────────┘
Current site: [edited]
Netlify TOML: /home/ether/code/cv-website/netlify.toml
Admin URL:    https://app.netlify.com/sites/[edited]
Site URL:     [edited]
Site Id:      418b94bc-93cd-411a-937a-ae4c734f17c4

@erezrokah erezrokah added type: bug code to address defects in shipped code area: functions labels Aug 20, 2020
@daixiang0
Copy link

@ehmicky @erezrokah is there any workaround or solution for this? I met this too.

@erezrokah
Copy link
Contributor

Sorry @daixiang0, but we haven't been able to look into this yet.
Also not sure if this should be handled in the CLI or in https://github.com/netlify/netlify-lm-plugin

@naavis
Copy link

naavis commented Jan 24, 2021

I am having the same problem on Windows 10 and Powershell 5.1. Running netlify lm:setup fails with TypeError: Cannot read property 'slug' of undefined after authorizing the application in my browser. I am trying to migrate from using Github LFS to Netlify Large Media, if that plays a role in this.

My netlify-cli version is netlify-cli/3.4.2 win32-x64 node-v14.15.3 and netlify-lm-plugin version is 1.0.0.

@erezrokah
Copy link
Contributor

Thanks for the additional information @naavis. We're in the process of moving https://github.com/netlify/netlify-lm-plugin into the CLI repo. We'll consider this issue during the migration

@justyn
Copy link

justyn commented Jan 26, 2021

I'm seeing exactly the same problem on Ubuntu 20.04.

@erwinkarim
Copy link

i'm seeing this exact same problem on macOS 11

@eduardoboucas eduardoboucas self-assigned this Feb 1, 2021
@MCJack123
Copy link

I'm experiencing this on both macOS 11 and Ubuntu 18.04. I'm using Node v14.x on both machines. However, I've examined this a bit and it appears this issue could be caused by a backend issue with the API.

The line causing the error as referenced in the OP (mine doesn't show the stack trace) points to calling the listAccountsForUser endpoint. It then looks for an account in the returned list that has type set to PERSONAL. I tried accessing this API endpoint for my account with netlify api, but it appears the type parameter is missing in the response:

$ netlify api listAccountsForUser | grep type
    "type_name": "Starter",
    "type_id": "5d2464889e975c00bab54e55",
    "type_slug": "starter",

The docs state that type should be defined, but it isn't in this response.

This doesn't excuse the fact that the script assumes it found an account without checking the result. A more user-friendly approach would be to check that account isn't null, and if it is print an actual error about that, instead of continuing and throwing a cryptic exception.

@eduardoboucas
Copy link
Member

We've been able to reproduce the issue and we're working on a fix as we speak. We'll update this issue as soon as it's fixed.

Thanks for your patience and for the detailed information! 🙌🏻

@erezrokah erezrokah reopened this Feb 3, 2021
@erezrokah
Copy link
Contributor

erezrokah commented Feb 3, 2021

Sorry for the trouble everyone.

While we figure this out can you try the following workaround

cd ~/.local/share/netlify-cli
# on Windows this should be `cd %LOCALAPPDATA%\netlify-cli`

npm i @netlify/cli-utils@latest 
# yarn also works
yarn add @netlify/cli-utils@latest

netlify lm:setup

@raphink
Copy link

raphink commented Feb 3, 2021

@erezrokah

Ubuntu 20.10 here.

After updating to @netlify/[email protected] as you suggested, I don't get the warning about opening the authorization URL anymore, but I still get the slug error:

❯ npm i @netlify/cli-utils@latest

npm WARN rm not removing /home/raphink/.local/share/netlify-cli/node_modules/.bin/semver as it wasn't installed by /home/raphink/.local/share/netlify-cli/node_modules/semver
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] requires a peer of listr@^0.14.2 but none is installed. You must install peer dependencies yourself.

+ @netlify/[email protected]
added 37 packages from 6 contributors, removed 262 packages, updated 365 packages and audited 403 packages in 32.39s

37 packages are looking for funding
  run `npm fund` for details

found 4 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details


   ╭───────────────────────────────────────────────────────────────╮
   │                                                               │
   │      New major version of npm available! 6.14.8 → 7.5.2       │
   │   Changelog: https://github.com/npm/cli/releases/tag/v7.5.2   │
   │               Run npm install -g npm to update!               │
   │                                                               │
   ╰───────────────────────────────────────────────────────────────╯

❯ netlify lm:setup
  ✔ Checking Git version [2.27.0]
  ✔ Checking Git LFS version [2.11.0]
  ✔ Checking Git LFS filters
  ✔ Installing Netlify's Git Credential Helper for Linux
  ✔ Configuring Git to use Netlify's Git Credential Helper
Logging into your Netlify account...
Opening https://app.netlify.com/authorize?response_type=ticket&ticket=4eb1a000a94e630bb619ef25139e5ee7
    TypeError: Cannot read property 'slug' of undefined

@erezrokah
Copy link
Contributor

erezrokah commented Feb 3, 2021

Hi @raphink, can you verify you ran that command inside ~/.local/share/netlify-cli? That directory is used to share dependencies for the CLI plugins

never mind - I can see that path in your log.

Can you config the new version is used by running npm ls @netlify/cli-utils inside that directory?

@raphink
Copy link

raphink commented Feb 3, 2021

Yes, I did, and this is what netlify resolves to:

Here you go @erezrokah

❯ pwd
/home/raphink/.local/share/netlify-cli
❯ which netlify
netlify: aliased to /usr/local/lib/node_modules/netlify-cli/bin/run
❯ npm ls @netlify/cli-utils
/home/raphink/.local/share/netlify-cli
├── @netlify/[email protected] 
└─┬ [email protected]
  └── @netlify/[email protected] 

@erezrokah
Copy link
Contributor

erezrokah commented Feb 3, 2021

@raphink yep, that doesn't look right. Let me see if I can find the correct place to force an update to that dependency.

@raphink
Copy link

raphink commented Feb 3, 2021

FYI, I just tried forcing it system wide with sudo, and it didn't work either.

@overlordofmu
Copy link

I believe some people have reported using an auth token copied from the web UI resolved the issue for them:

https://docs.netlify.com/cli/get-started/#obtain-a-token-in-the-netlify-ui

@erezrokah
Copy link
Contributor

Thanks @overlordofmu I totally overlook that angle. That should work

@overlordofmu
Copy link

It is only a workaround but it does get some people "working" again while a fix in the CLI tool is being developed.

@jameshfisher
Copy link

I believe some people have reported using an auth token copied from the web UI resolved the issue for them:

https://docs.netlify.com/cli/get-started/#obtain-a-token-in-the-netlify-ui

Hey @overlordofmu, could you expand on this? Setting this env var does not make any difference for me:

$ NETLIFY_AUTH_TOKEN=my_auth_token netlify lm:setup
Logging into your Netlify account...
Opening https://app.netlify.com/authorize?response_type=ticket&ticket=qwertyuiopkjhgfdsazxcvbnm
    TypeError: Cannot read property 'slug' of undefined

Is this what I should be doing, or is the workaround different somehow?

@uncasually
Copy link

Hey everyone

Found a workaround that worked for me on Mac.

  • added NETLIFY_AUTH_TOKEN as and environment variable to terminal
  • since I was having issues with npm, I ran it in yarn yarn add @netlify/cli-utils@latest in ~/.local/share/netlify-cli
  • after that, navigated back to the already linked folder and ran netlify lm:setup and it FINALLY worked.

I suspect for me is because I am behind some versions on npm maybe since running npm i -g netlify-cli@latest resulted in some npm warnings.

Hope it helps some of you.

@erezrokah
Copy link
Contributor

erezrokah commented Feb 14, 2021

Hi all 👋 and sorry for the delay in fixing this.
CLI version 3.8.0 address this issue.
Please comment if you're still experiencing issues after running:

npm i -g netlify-cli
netlify lm:setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.