Yarn throws an error while trying to build electron app - windows

When I try to create an electron app via yarn create electron-app "my-app", it throws an error saying
'C:\Users\Lincoln' is not recognized as an internal or external command,
operable program or batch file.
error Command failed.
Exit code: 1
Command: C:\Users\Lincoln Muller\AppData\Local\Yarn\bin\create-electron-app
Arguments: my-app
Directory: C:\Users\Lincoln Muller
Output:
What should I do? I'm new to Yarn, and NPM worked fine. This also only happens on Windows, when I use my iMac on Monterey or my Linux laptop the command runs fine.

It seems that Yarn assumes it can run the program create-electron-app without considering spaces in the file path. Unfortunately, this does not work and only the part up to the first space is considered a program to run, hence you get the error message that C:\Users\Lincoln is not a valid command.
The problem is discussed in this Yarn issue. The key idea in the workarounds is to accept Yarn's behavior and give it a file path that doesn't contain spaces. There are two concrete ideas:
Option A - Use directory name abbreviation to skip the space
yarn config set cache-folder "C:\Users\Lincol~1\AppData\Local\Yarn\Cache"
yarn config set prefix "C:\Users\Lincol~1\AppData\Local\Yarn"
For this to work, make sure to take 6 characters from the actual directory name and then append ~1. If the space happens to occur within the first 6 characters, this approach will not work for you.
Option B - Make another user folder, skipping the space (using junction)
mklink /J "C:\Users\Lincoln-Muller" "C:\Users\Lincoln Muller"
yarn config set cache-folder "C:\Users\Lincoln-Muller\AppData\Local\Yarn\Cache"
yarn config set prefix "C:\Users\Lincoln-Muller\AppData\Local\Yarn"
A junction allows two directory names to point at the same file system structure. That means that there are two ways to address the same directory. Their contents cannot diverge because they are the same directory.

The issue is that you have a space in your directory name and you haven't correctly escaped it.
C:\Users\Lincoln Muller
This looks like you are trying to pass the parameter Muller to program C:\Users\Lincoln
I suggest just using a folder that doesn't contain spaces or escape the [space character].
https://www.howtogeek.com/694949/how-to-escape-spaces-in-file-paths-on-the-windows-command-line/
Three Ways to Escape Spaces on Windows There are three different ways
you can escape file paths on Windows:
By enclosing the path (or parts of it) in double quotation marks ( ”
).
By adding a caret character ( ^ ) before each space. (This only
works in Command Prompt/CMD, and it doesn’t seem to work with every
command.)
By adding a grave accent character ( ` ) before each space.
(This only works in PowerShell, but it always works.)

Related

Problem running package in directory with whitespace on windows 10

Through the terminal I ran
yarn create xxxxxxx-app in a directory that had whitespace in the URL, but it failed because it couldn't understand the complete URL. So I changed to a directory that didn't have any spaces in it to run the same command and it failed using the same internal path as the previous.
The package installs the scripts and binaries where it should but when it tries to run them, it tries to use the original URL that has the whitespace and fails
Example in a directory with or without whitespace:
runs: C:\Users\First Last\AppData\Local\Yarn\bin\xxxxxxxxx-app
"C:\Users\First" isn't recognized as an internal or external command,
error Command failed.
So internally it uses the same command as the one that failed orginially even though it was run in another directory
both respond as follows:
Exit code: 1
Command: C:\Users\First Last\AppData\Local\Yarn\bin\xxxxxxxxxx-app
Arguments: ./xxxxxxxblog
Directory: C:\Users\First_Last\Github\David-Ventures1
I found that the problem is that the package uses my user account no matter where I try to run the script, and unfortunately my user directory has whitespace in it.
So I need to remove the whitespace.... I tried a couple of times a little while ago but nearly bricked my computer...

How do i use XCOPY with spaces in both paths, even with quotes?

I am trying to create a batch file that copies files from one path to another, using several xcopy commands. However, the batch script fails because Xcopy apparently has the wrong number of parameters.
I believe the reason is that it thinks the spaces in my folder paths are separating parameters- but I do not know why it is doing this because I have made sure that both the source and destination paths are surrounded with double-quotes.
for example, I run this command in my batch script:
c:/windows/system32/xcopy.exe "H:\some path with spaces\myfile.txt" "H:\some path with spaces\a_different_folder\myfile.txt" /Y
and it outputs this:
Invalid number of parameters
Can somebody please tell me what I'm doing wrong or if there is a workaround?
I have also tried using the standard copy command, but that ends up saying the system cannot find the path specified (which isn't true, as my batch file is actually generated by a script that uses the paths of files that are guaranteed to exist)
as #Mark said:
It is your path to xcopy. It is wrong. It is why you are getting the message. C: is a valid command. It will choose a valid command over fixing unix's paths

Can't Copy folder to specific location using terminal - Mac

I could not find a usable solution to this seemingly simple problem, despite my best efforts.
I'm using MacOS High Sierra 10.13.6
I have a folder I want to copy with the following location:
/Users/ep9k/Desktop/Key-LogEcovaluator/whereami
I want to copy it to this directory using the terminal:
/Users/ep9k/Library/Application/Support/QGIS/QGIS3/profiles/default/python/plugins
I tried the following commands in the terminal. Notice I am in the 'whereami' folder when doing this:
whereami ep9k$ cp -r /Users/ep9k/Desktop/Key-LogEcovaluator/whereami /Users/ep9k/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
whereami ep9k$ cp -a /Users/ep9k/Desktop/Key-LogEcovaluator/whereami /Users/ep9k/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
I'm met with the following message indicating I am not using it correctly:
However, I created a "tester" folder on my desktop and can copy to this folder with no problems, using exactly the same command (except with the pathname changed to my tester folder).
I can also copy and paste things to this directory using the GUI "finder". What am I missing?
Your destination path contains at least one whitespace character ("Application Support"), which causes the "cp" command to think it's being given three arguments instead of two. Enclose the destination path in single or double quotes and you should be all right.

Windows Jenkins How do i use WORKSPACE system parameter when it has spaces?

I'm using Jenkins over windows 7 and i encountered strange behavior.
when im trying to copy files to working directory - represented in Jenkins by the system parameter WORKSPACE, for example like in this code:
cp -a hpdevops-discovery-demoapp-master/. $WORKSPACE/
i get the following:
cp -a hpdevops-discovery-demoapp-master/. 'C:\Program' Files '(x86)\Jenkins\workspace\jenkins-AutomationFreeStyle-Pipeline-2/'
cp: target '(x86)\Jenkins\workspace\jenkins-AutomationFreeStyle-Pipeline-2/' is not a directory
what's happening: the workspace located here: C:\Program' Files '(x86)\Jenkins\workspace\jenkins-AutomationFreeStyle-Pipeline-2/
but, because of the space in the path after the word 'Files' its deviding it into 2 and treating the second part - which is just half of the path, as the target path: '(x86)\Jenkins\workspace\jenkins-AutomationFreeStyle-Pipeline-2/'
i used to work with Jenkins on Linux and never had a problem like this when using the WORKSPACE system parameter.
anyone run into this?
use double quote wrap it like "$WORKSPACE"

Why shouldn't I put spaces in my Maven path in Windows?

In the Maven Windows prerequisites, it states,
You need to unpack the Maven distribution. Don't unpack it in the middle of your source code; pick some location (with no spaces in the path!) and unpack it there.
Why does it matter if there are spaces in the path or not?
The problem is that somewhere in Maven, it is executing a sub process and it is not properly wrapping its file name arguments in double quotes. So a file that is at
"C:\Program Files\Foobar"
will look like 2 files on the command line
"C:\Program"
"Files\Foobar"
and neither of those are correct. This is a holdover from the "old" days when spaces were not allowed in file names (ie 1980s) and spaces separated arguments on the command line. It's a shame that this problem still exists. It's slightly worse on Linux machines, which have been slower to migrate to allowing spaces in file names, so there are more scripts and programs on Linux which fail if you have spaces in the file names.

Resources