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

cannot run yarn create if yarn is in a folder where the file path has a space #6851

Open
liverpoologic opened this issue Dec 24, 2018 · 16 comments
Assignees
Labels

Comments

@liverpoologic
Copy link

Yarn v1.12.3
my laptop (helpfully, thank you windows) installed yarn by default in a directory where the file path includes a space (e.g. C:/Users/Some Name/AppData/Yarn...).
This results in the following error when I run yarn create react-app

'C:\Users\Some' is not recognized as an internal or external command,
operable program or batch file.
error Command failed.
Exit code: 1
Command: C:\Users\Some Name\AppData\Local\Yarn\bin\create-react-app
Arguments:
Directory: C:\repos\beaver
Output:
@ghost ghost assigned torifat Dec 24, 2018
@ghost ghost added the triaged label Dec 24, 2018
@crossoft
Copy link

Just spent an hour on this very issue until realizing this was the cause - spaces in the profile name.

@crossoft
Copy link

If easy, putting quotes around the command would resolve it and still work with non-spaced paths

@BartArys
Copy link

BartArys commented Dec 7, 2019

It's been a year now, can we get an update on this?

@lvizrosario
Copy link

lvizrosario commented Aug 5, 2020

You need to change the cache to a location without spaces.

yarn config set cache-folder "your path without spaces"

Did work for me!! If this solve your problems, let me know!

@chase-meyer
Copy link

I also had to change the prefix

yarn config set prefix "your path without spaces"

#6630

@q00u
Copy link

q00u commented Feb 3, 2021

It is now 2021 and this is still not fixed.

nvm puts node in C:\Program Files\nodejs

yarn create puts the creator in [node directory]\bin

The result of every yarn create whatever is

success Installed "[email protected]" with binaries:
      - create-react-app
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
error Command failed.
Exit code: 1
Command: C:\Program Files\nodejs\bin\create-react-app

npm/npx doesn't have this problem.

@ZombieChibiXD
Copy link

ZombieChibiXD commented Mar 25, 2021

I have a fix and proposed solution for this!
It involves around changing the config, but I hope the devs try to make a workaround around spaced folder by utilizing FolderName~1 style solution.

Solution for the meantime:

First, run these commands
yarn cache dir
yarn global bin

It'll output something like:
C:\Users\Firstname Lastname\AppData\Local\Yarn\Cache\v6
C:\Users\Firstname Lastname\AppData\Local\Yarn\bin

Copy those, and next run this, with slight modification according to your username Firstname:
yarn config set cache-folder "C:\Users\Firstname~1\AppData\Local\Yarn\Cache" (without the V6)
yarn config set prefix "C:\Users\Firstname~1\AppData\Local\Yarn" (without the bin)

This is not a workaround, this is a fix, and other workarounds that revolves around moving your Yarn configs to a new folder may cause PATH or Environment Variables issue!

Hope this fixes your problem.

@espenja
Copy link

espenja commented Oct 27, 2021

@ZombieChibiXD's solution did not work for me, but combining their solution with the solution proposed over at vitejs/create-vite-app#23 (comment) for npm did.

Problematic path used as example: C:\Users\Espen Jacobsson

Steps taken:

  • Close any running shell
  • Run cmd in Administrative Mode (mklink is a feature of cmd, and won't work in PowerShell)
  • Create a directory junction (directory hard link) using the mklink command:
    • mklink /J "C:\Users\EspenJacobsson" "C:\Users\Espen Jacobsson"
  • Run commands
    • yarn cache dir
    • yarn global bin

Take note of the output, as stated in the comment above, they will look something like this:
C:\Users\Espen Jacobsson\AppData\Local\Yarn\Cache\v6
C:\Users\Espen Jacobsson\AppData\Local\Yarn\bin

  • Run commands:

    • yarn config set cache-folder "C:\Users\EspenJacobsson\AppData\Local\Yarn\Cache" (without the V6)
    • yarn config set prefix "C:\Users\EspenJacobsson\AppData\Local\Yarn" (without the bin)
  • Reload your shell and verify the new paths are set with the yarn cache dir and yarn global bin commands

  • Assuming the paths are correctly changed, yarn create should now hopefully be working

Hope this helps anyone 🙂

@ValorLin
Copy link

@ZombieChibiXD's solution looks fancy, but it doesn't work for everyone.

The right way to find the short path should be running dir /x in C:\Users.

image

It's VALORL~1 for me instead of VALOR~1.

@sirpasha
Copy link

I have a fix and proposed solution for this! It involves around changing the config, but I hope the devs try to make a workaround around spaced folder by utilizing FolderName~1 style solution.

Solution for the meantime:

First, run these commands yarn cache dir yarn global bin

It'll output something like: C:\Users\Firstname Lastname\AppData\Local\Yarn\Cache\v6 C:\Users\Firstname Lastname\AppData\Local\Yarn\bin

Copy those, and next run this, with slight modification according to your username Firstname: yarn config set cache-folder "C:\Users\Firstname~1\AppData\Local\Yarn\Cache" (without the V6) yarn config set prefix "C:\Users\Firstname~1\AppData\Local\Yarn" (without the bin)

This is not a workaround, this is a fix, and other workarounds that revolves around moving your Yarn configs to a new folder may cause PATH or Environment Variables issue!

Hope this fixes your problem.

After hours of struggling with this issue, @ZombieChibiXD solution worked for me.

@isogunro
Copy link

isogunro commented Jul 8, 2022

You need to change the cache to a location without spaces.

yarn config set cache-folder "your path without spaces"

Did work for me!! If this solve your problems, let me know!

HOW?

@alexandre-le-borgne
Copy link

alexandre-le-borgne commented Jul 19, 2022

image

Still a problem in 2022, incredible...

@nikki-cat
Copy link

nikki-cat commented Aug 23, 2022

This is happening to me too .... :( My laptop is a company laptop with was pre--setup by someone else, who wasnt aware of spaces being a problem. Is there any fix for this?

Edit: Just for info, #6851 (comment) worked for me too.

@Adambean
Copy link

Adambean commented Oct 9, 2022

I too am amazed to find this is still a problem in 2022. On Windows we've regularly had spaces in directory names since Windows 95, and on Linux the first ext file system had it since 1992. This should not still be a problem 27/30 years later.

Many of the workarounds above will not work because the Yarn configuration file ".yarnrc" exists in our user home directory which is a very common place for a space to be present at, so any configuration change you make (even with the junction or symbolic link approach) will not persist.

@muhammad-shahin
Copy link

yarn config set cache-folder "C:\path\without\spaces\.yarn-cache"
yarn config set prefix "C:\path\without\spaces\.yarn"

just run these two command and confirm changes using this command
yarn config list

Thank me later <3

@Tanujch03
Copy link

Run this command in command prompt:
yarn config set prefix "\AppData\Local\bin"
Screenshot 2024-03-06 213445

U are good to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests