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

Poetry Command Not Found on zsh #507

Closed
3 tasks done
swarnakumar opened this issue Oct 18, 2018 · 27 comments
Closed
3 tasks done

Poetry Command Not Found on zsh #507

swarnakumar opened this issue Oct 18, 2018 · 27 comments

Comments

@swarnakumar
Copy link

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: <macOS 10.14 Mojave>
  • Poetry version: <0.12.2>

Issue

I am a noob to poetry, and just installed poetry using the curl command.

I got the following:

Retrieving Poetry metadata

# Welcome to Poetry!

This will download and install the latest version of Poetry,
a dependency and package manager for Python.

It will add the `poetry` command to Poetry's bin directory, located at:

$HOME/.poetry/bin

This path will then be added to your `PATH` environment variable by
modifying the profile files located at:

$HOME/.profile
$HOME/.zprofile

You can uninstall at any time with `poetry self:uninstall`,
or by executing this script with the --uninstall option,
and these changes will be reverted.

Installing version: 0.12.2
  - Downloading poetry-0.12.2-darwin.tar.gz (7.00MB)

Poetry (0.12.2) is installed now. Great!

To get started you need Poetry's bin directory ($HOME/.poetry/bin) in your `PATH`
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run `source $HOME/.poetry/env`

But when I start a new shell, and run poetry --version, I get:
zsh: command not found: poetry

Works fine if I do source $HOME/.poetry/env. But doesn't retain for a new shell. I have to do this every time I open a new shell.

@sdispater
Copy link
Member

If you do:

echo $PATH

What does it give you?

@swarnakumar
Copy link
Author

In a newly opened shell:

/usr/local/opt/node@8/bin:/Users/swarnavallabhaneni/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

And after sourcing via source $HOME/.poetry/env

/Users/swarnavallabhaneni/.poetry/bin:/usr/local/opt/node@8/bin:/Users/swarnavallabhaneni/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

@sdispater
Copy link
Member

So your shell does not source neither the .zprofile file nor the .profile file. That's weird since ~/.zprofile should always be sourced by zsh.

If it's not you might want to do it yourself in your .zshrc file.

Just to be sure: has export PATH="$HOME/.poetry/bin:$PATH" been added to ~/.zprofile?

@swarnakumar
Copy link
Author

Its weird.

I don't have a ~/.zprofile at all.

I do have a ~/.profile and that does have the line export PATH="$HOME/.poetry/bin:$PATH"

Is it oh-my-zsh doing something?

@swarnakumar
Copy link
Author

swarnakumar commented Oct 18, 2018

I have added export PATH="$HOME/.poetry/bin:$PATH" to the my .zshrc, and things work.

I notice that Google Cloud SDK automatically appended its path and path completions to my .zshrc. Maybe thats something poetry could also do?

Closing this issue.

@sdispater
Copy link
Member

Just to check: if you create a ~/.zprofile and add export PATH="$HOME/.poetry/bin:$PATH" to it and then restart your shell, does it work? 

@swarnakumar
Copy link
Author

Yes it does.

@xobust
Copy link

xobust commented Jan 23, 2019

I had the same issue, my system does not have a .profile and zsh does not create a .zprofile by default.
Poetry installed in my .bash_profile. Consider adding export PATH="$HOME/.poetry/bin:$PATH" to .zshrc if no .zprofile exists.

@JayWelsh
Copy link

JayWelsh commented Jul 2, 2019

zsh mainly uses .zshrc, it would definitely be a good idea to check for .zshrc if no .zprofile exists. Just ran into the same issue.

@ffe4
Copy link
Contributor

ffe4 commented Apr 6, 2020

I'd like to mention users are still running into this issue and it would be nice if it was reopened and addressed, either during installation or in the docs.

@lggwettmann
Copy link

Yes, same issue here.

@khanguslee
Copy link

Can also confirm that this does not automatically happen. As a user, I would have expected the PATH to have been updated upon installation.

@Oscar-Rod
Copy link

Same here, I just installed it using the cURL, and in my system I only have the .zshrc, which was not updated with the export PATH="$HOME/.poetry/bin:$PATH"

@schlich
Copy link

schlich commented May 13, 2020

i'm on linux and also ran into this issue... similarly to those above the workaround of adding export PATH="$HOME/.poetry/bin:$PATH" to my ~/.bashrc file worked

@thatguycodes
Copy link

Still running into the same issue.

@Dminor7
Copy link

Dminor7 commented Aug 5, 2020

So your shell does not source neither the .zprofile file nor the .profile file. That's weird since ~/.zprofile should always be sourced by zsh.

If it's not you might want to do it yourself in your .zshrc file.

Just to be sure: has export PATH="$HOME/.poetry/bin:$PATH" been added to ~/.zprofile?

If the PATH for poetry is there in .profile then you have to just logout from the current session and log in again. The changes in .profile will be reflected.

@adam-grant-hendry
Copy link

Same issue. No .zprofile is created. Also, .poetry folder is not created. I have Windows 10 with WSL2. Running which poetry points to my Windows poetry install and trying poetry install gives error /usr/bin/env: ‘python\r’: No such file or directory. Something is up...

@adam-grant-hendry
Copy link

Running pip install poetry at first yields

Defaulting to user installation because normal site-packages is not writeable
Collecting poetry
  Using cached poetry-1.0.10-py2.py3-none-any.whl (224 kB)

then packages install. Is the user install pointing to the Windows user folder rather than the WSL distro user folder?

@adam-grant-hendry
Copy link

Even trying pip install --user poetry does not solve the problem. Only manually creating ~/.zprofile and executing export PATH="$HOME/.poetry/bin:$PATH" fixes problem.

@sdispater and @abn do we know why this is still happening?

@schlich
Copy link

schlich commented Sep 2, 2020

I should have clarified on my comment above that I am also on WSL, although I was on WSL1 at time i encountered the bug

@xobust xobust mentioned this issue Oct 3, 2020
2 tasks
@HHogg
Copy link

HHogg commented Oct 29, 2020

This issue might need to be reopened as it's still an issue, and just means the install flow isn't as smooth. I had the same issue as I didn't have a .zprofile or a .profile so just had to add the path myself in the .zshrc file.

@davidfstr
Copy link

Issue still exists, and should be reopened.

zsh is the default shell for new installations of macOS for the last several major OS releases. Therefore having this issue not fixed means that Poetry will not be usable after installation by default on new macOS machines & VMs.

@emk5389
Copy link

emk5389 commented Jun 8, 2022

I was experiencing a similar issue with a bash shell running on WSL2. I was connecting to it via the remote development extension for VScode. I noticed that if I directly accessed my WSL2 VM by opening the Ubuntu application, the shell was sourcing the .profile and could find the poetry command. Then, suspecting it was a VScode remote development problem, I started googling and found this issue. Pretty interesting how VScode works, but long story short: if you're having issues with poetry not being added to your path and you're using WSL2 and VScode remote development to connect, try closing all of your VScode windows, wait a few seconds, and then try again. Then starting a new terminal connected to your WSL2 VM on VSCode should have poetry in your path. Posting here in case it helps anyone else resolve this issue.

@DoodlesEpic
Copy link

Had the same problem today, was left scratching my head. Noticed it worked on bash. On a default installation of oh-my-zsh, the PATH variables won't have $HOME/.local/bin added to it. I didn't notice this when changing my system shell because Rust Cargo which also has a binary there modifies the environment and sources a binary located elsewhere too. However, instead of using the export PATH provided by Poetry, I copied mine from my .bashrc, which was as follows:

# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH

@kingofsevens
Copy link

I did a fresh install with zsh and prezto installed. Below is the same case with me. Poetry installs to .local  even though I haven't had any .local  directory before...

# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH

@alfmorais
Copy link

Hello everbody,

I have same problem when installed the poetry for the first time.
I just restart my computer and the command poetry --version works for me.

I'm using the Linux Mint 21.

Best Regards

@neersighted
Copy link
Member

Hi all,

I am locking this issue as it originally refers to the old installer which managed your PATH for you. With the new install methods, the responsibility for modifying the $PATH (both in the current session and in the shell configuration) is returned to the user.

This is because knowing what is correct on any given user's machine (and making the change/undoing it cleanly) is very fraught, and most power users object to automated modification of their shell configuration. If you are having issues adding Poetry to your PATH, please start a Discussion or make use of resources like Stack Overflow as this is a very generic problem.

@python-poetry python-poetry locked as resolved and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet