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

Using Yarn to install dependencies on Mac results in file encoding issues (CRLF) #967

Closed
Seanom opened this issue Oct 31, 2018 · 21 comments
Closed

Comments

@Seanom
Copy link

Seanom commented Oct 31, 2018

I am using Pattern Lab Node v3.0.0.0-beta.1 on Mac High Sirerra, with Node v10.11.0, using a Vanilla Edition.

There is an issue when using Yarn on unix based systems, I'm using a Mac but I've seen people using Ubuntu experience the same problem and I've not seen it jotted down yet here.

When running 'yarn' files are installed using the encoded line breaks, it appears that NPM changes this to the system specific version. However if the file is encoded with CRLF then this results in the following message

env: node\r: No such file or directory

This does not occur on windows, and only appears if you install using yarn to get around this it's possible to install using npm install and then using yarn to run scripts

There is an issue about this over on the yarn github page yarnpkg/yarn#5480
I've also spotted a couple of people in the pattern lab gitter.im channel.

Expected Behavior

Files are encoded using LF line separators

Actual Behavior

Many of the files are encoded using CRLF line separators, which results in the error when using yarn

env: node\r: No such file or directory
Steps to Reproduce

Reproduced on a mac High Sierra 10.13.6

  • Ensure the package.json exists (I used the following)
     {
      "name": "test",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "pl:build": "patternlab build --config ./patternlab-config.json",
        "pl:help": "patternlab --help",
        "pl:install": "patternlab install --config ./patternlab-config.json",
        "pl:serve": "patternlab serve --config ./patternlab-config.json",
        "pl:version": "patternlab --version"
      },
      "keywords": [],
      "author": "",
      "license": "ISC",
      "dependencies": {
        "@pattern-lab/cli": "^0.0.1-beta.1",
        "@pattern-lab/core": "^3.0.0-beta.1",
        "@pattern-lab/engine-mustache": "^2.0.0-beta.0",
        "@pattern-lab/uikit-workshop": "^1.0.0-beta.0"
      }
     }
    
  • Run yarn (everything installs)
  • Run yarn pl:help
  • Observe the error message
    yarn run v1.10.1
    $ patternlab --help
    env: node\r: No such file or directory
    error Command failed with exit code 127.
    

It's also possible to run the following

  • npm init -y && npx @pattern-lab/cli -c patternlab init
  • Leave the directory as default
  • Install node version
  • Select None for the starter template
  • Once installed delete the node_modules folder
  • Run yarn
  • Run yarn pl:help
  • Observe, the error message as above
@Seanom Seanom changed the title Using Yarn to install dependencies Using Yarn to install dependencies on Mac results in file encoding issues (CRLF) Nov 2, 2018
@DanielRuf
Copy link
Contributor

DanielRuf commented Nov 2, 2018

Same here, using latest version of Yarn stable and Node 10 LTS.

@stale
Copy link

stale bot commented Jan 1, 2019

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@stale
Copy link

stale bot commented Jan 19, 2019

Issue closed after going stale. It can be re-opened if still relevant.

@stale stale bot closed this as completed Jan 19, 2019
@DanielRuf
Copy link
Contributor

I hate such bots like the stale bot.

@engelfrost engelfrost reopened this Jan 21, 2019
@jp-sauve
Copy link

jp-sauve commented Feb 9, 2019

This is still relevant.

{
  "name": "patternlab",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "patternlab": "patternlab",
    "pl:build": "patternlab build --config ./patternlab-config.json",
    "pl:help": "patternlab --help",
    "pl:install": "patternlab install --config ./patternlab-config.json",
    "pl:serve": "patternlab serve --config ./patternlab-config.json",
    "pl:version": "patternlab --version"
  },
  "devDependencies": {
    "@pattern-lab/cli": "^0.0.1-beta.1"
  },
  "dependencies": {
    "@pattern-lab/cli": "^0.0.1-beta.1",
    "@pattern-lab/core": "^3.0.0-beta.1",
    "@pattern-lab/engine-mustache": "^2.0.0-beta.0",
    "@pattern-lab/uikit-workshop": "^1.0.0-beta.0",
    "starterkit-twig-drupal-demo": "pattern-lab/starterkit-twig-drupal-demo"
  }
}

and here's some log output for you. I'm using Linux.

1 verbose cli [ '/home/fathead/.nvm/versions/node/v10.5.0/bin/node',
1 verbose cli   '/home/fathead/.nvm/versions/node/v10.5.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'patternlab',
1 verbose cli   '--',
1 verbose cli   'serve' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prepatternlab', 'patternlab', 'postpatternlab' ]
5 info lifecycle [email protected]~prepatternlab: [email protected]
6 info lifecycle [email protected]~patternlab: [email protected]
7 verbose lifecycle [email protected]~patternlab: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~patternlab: PATH: /home/fathead/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/fathead/Workspace/patternlab/node_modules/.bin:/home/fathead/.yarn/bin:/home/fathead/.config/yarn/global/node_modules/.bin:/home/fathead/.nvm/versions/node/v10.5.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/home/fathead/bin:/home/fathead/.npm-packages/bin
9 verbose lifecycle [email protected]~patternlab: CWD: /home/fathead/Workspace/patternlab
10 silly lifecycle [email protected]~patternlab: Args: [ '-c', 'patternlab "serve"' ]
11 info lifecycle [email protected]~patternlab: Failed to exec patternlab script
12 verbose stack Error: [email protected] patternlab: `patternlab "serve"`
12 verbose stack spawn ENOENT
12 verbose stack     at ChildProcess.<anonymous> (/home/fathead/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack     at ChildProcess.emit (events.js:182:13)
12 verbose stack     at maybeClose (internal/child_process.js:961:16)
12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
13 verbose pkgid [email protected]
14 verbose cwd /home/fathead/Workspace/patternlab
15 verbose Linux 4.15.0-45-generic
16 verbose argv "/home/fathead/.nvm/versions/node/v10.5.0/bin/node" "/home/fathead/.nvm/versions/node/v10.5.0/bin/npm" "run" "patternlab" "--" "serve"
17 verbose node v10.5.0
18 verbose npm  v6.1.0
19 error file sh
20 error code ELIFECYCLE
21 error errno ENOENT
22 error syscall spawn
23 error [email protected] patternlab: `patternlab "serve"`

@DanielRuf
Copy link
Contributor

This is still relevant.

Sure, this is why it was reopened ;-)

@zachariab
Copy link

Upgrading @pattern-lab/cli to 0.0.1-beta.2 resolved this issue for me. I'm not quite sure why, though.

I verified there are CRLF line separators in the file packages/cli/bin/patternlab.js at 0.0.1-beta.1 that are fixed in 0.0.1-beta.2. That's true using either yarn or npm, although npm changes the first line break to at LF preventing the "No such file or directory" error.

The mystery is I couldn't find a commit that would change the line ending in that file between beta.1 and beta.2. In any case, it's working for me now.

@zachariab
Copy link

zachariab commented Mar 29, 2019

My best guess is that this is related to the npm issue npm publish from Windows handles CRLF incorrectly

Is it possible that the releases prior to 0.0.1-beta.2 were published from a windows machine but newer ones from mac/unix? That would explain the CRLF I'm seeing in previous releases, which npm fixes but yarn does not.

@stale
Copy link

stale bot commented May 28, 2019

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@DanielRuf
Copy link
Contributor

Not stale, still relevant.

@stale
Copy link

stale bot commented Jul 27, 2019

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@stale
Copy link

stale bot commented Sep 25, 2019

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@DanielRuf
Copy link
Contributor

Not stale.

@stale
Copy link

stale bot commented Nov 24, 2019

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@stale
Copy link

stale bot commented Dec 24, 2019

Issue closed after going stale. It can be re-opened if still relevant.

@stale stale bot closed this as completed Dec 24, 2019
@bradjones1
Copy link

Not stale.

@roman-sitewits
Copy link

Still relevant!!!

Also here is the yarn bug:
yarnpkg/yarn#5480

@theLine
Copy link

theLine commented Sep 21, 2021

I'm getting the same error on MacOS 11.6.
It seems that it doesn't matter whether I use yarn (1.22.11) or npm (6.14.13) with node v14.
The executable (node_modules/.bin/patternlab) still will get windows line-endings.

EDIT: I found a workaround. I've installed dos2unix-cli and added a postinstall hook in the package.json:

  "scripts": {
    "postinstall": "dos2unix node_modules/.bin/patternlab"
  },

@stale
Copy link

stale bot commented Jan 9, 2022

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@mfranzke
Copy link
Contributor

@Seanom it looks like that we finally solved this problem with #1397, I cannot reproduce the problem any more with the newest pattern lab version 5.16.1

@wesleyboar
Copy link

wesleyboar commented Feb 3, 2022

I also cannot reproduce the issue since v5.16.1. (I could reproduce it with an earlier version—I forgot which.)

Details

I am using Pattern Lab Node v5.16.1 on Mac Monterey, with Node v17.4.0, using a Vanilla Edition.

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

No branches or pull requests