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

ZSH: Getting strange grep: x: Is a directory in my terminal, as well as unexpected parsing of files #2364

Closed
Xananax opened this issue Nov 27, 2020 · 5 comments

Comments

@Xananax
Copy link

Xananax commented Nov 27, 2020

Operating system and version:

Arch Linux

nvm debug output:

nvm --version: v0.37.1
$SHELL: /usr/bin/zsh
$SHLVL: 3
whoami: 'xananax'
${HOME}: /home/xananax
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v12.18.4/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8 (x86_64-pc-linux-gnu)'
uname -a: 'Linux 5.9.10-arch1-1 #1 SMP PREEMPT Sun, 22 Nov 2020 14:16:59 +0000 x86_64 GNU/Linux'
checksum binary: 'sha256sum'
OS version: Arch Linux  ()
curl: /usr/bin/curl, curl 7.73.0 (x86_64-pc-linux-gnu) libcurl/7.73.0 OpenSSL/1.1.1h zlib/1.2.11 zstd/1.4.5 libidn2/2.3.0 libpsl/0.21.1 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.41.0
wget: /usr/bin/wget, GNU Wget 1.20.3 built on linux-gnu.
git: /usr/bin/git, git version 2.29.2
ls: cannot access 'grep:': No such file or directory
grep: grep: aliased to grep --color=auto (grep --color=auto), grep (GNU grep) 3.6
awk: /usr/bin/awk, GNU Awk 5.1.0, API: 3.0 (GNU MPFR 4.1.0, GNU MP 6.2.0)
sed: /usr/bin/sed, sed (GNU sed) 4.8
cut: /usr/bin/cut, cut (GNU coreutils) 8.32
basename: /usr/bin/basename, basename (GNU coreutils) 8.32
rm: /usr/bin/rm, rm (GNU coreutils) 8.32
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.32
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.7.0
nvm current: v12.18.4
which node: ${NVM_DIR}/versions/node/v12.18.4/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v12.18.4/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v12.18.4
npm root -g: ${NVM_DIR}/versions/node/v12.18.4/lib/node_modules

nvm ls output:

->     v12.18.4
       v14.11.0
         system
default -> lts/* (-> v12.18.4)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v14.11.0) (default)
stable -> 14.11 (-> v14.11.0) (default)
lts/* -> lts/erbium (-> v12.18.4)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.22.1 (-> N/A)
lts/erbium -> v12.18.4

How did you install nvm?

Using the Arch package

What it does is put the completion, binaries, and so on in the right place. You can see the script for it here

After that, I added source /usr/share/nvm/init-nvm.sh to my .zshrc.

This script is just:

[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
source /usr/share/nvm/nvm.sh
source /usr/share/nvm/bash_completion
source /usr/share/nvm/install-nvm-exec

What steps did you perform?

I updated the package

What happened?

When I open a terminal, I get:

grep: Desktop: Is a directory
grep: Downloads: Is a directory
...etc

This also happens on TTY, with no graphical server running at all.

If I open a terminal in specific directories (in this occurrence an Electron project), I get additional weirdness:

grep: node_modules: Is a directory
grep: out: Is a directory
grep: src: Is a directory
grep: static: Is a directory 
(eval):1: command not found: forge.config.js
nvm is not compatible with the "README.md:- [`forge.config.js`](./forge.config.js): decides which packages are used by Electron Forge. In particular, it sets the exporters (Windows, Mac, Linux, ...)" environment variable: currently set to ".md:- [](./forge.config.js): decides which packages are used by Electron Forge. In particular, it sets the exporters (Windows, Mac, Linux, ...)"
Run `unset README.md:- [\`forge.config.js\`](./forge.config.js): decides which packages are used by Electron Forge. In particular, it sets the exporters (Windows, Mac, Linux, ...)` to unset it.

Of course, the sentence

- [`forge.config.js`](./forge.config.js): decides which packages are used by Electron Forge. In particular, it sets the exporters (Windows, Mac, Linux, ...)

is part of my README.md and describes the project's architecture.

The string forge.config.js only exists in the README.md and as a config key in `package.json.

> grep -R "forge.config.js" --exclude-dir node_modules
package.json:    "forge": "./forge.config.js"
README.md:- [`forge.config.js`](./forge.config.js): decides which packages are used by Electron Forge. In particular, it sets the exporters (Windows, Mac, Linux, ...)

If I remove that sentence from the README, then nvm tells me this:

nvm is not compatible with the "package.json:    "forge": "./forge.config.js"" environment variable: currently set to ".json:    forge: ./forge.config.js"

If I remove that, then I am back to the more "normal" error, which tells me grep: <x>: Is a directory.

Removing only the line in package.json isn't sufficient, however, I have to remove it from the README.md too.

So nvm is deciding on its own to... parse the README.md, extract some specific string for some reason, then eval it? Then decide that there's an environment variable equal to the whole line?

Notice the environment variable's name starts with README.md: ... but it's value is set to .md: ...

I can confirm these issues come from the interaction of nvm and zsh, because:

  • if I do not source nvm.sh, and/or
  • if I use bash

I don't get any of these lines.

Apart for these annoying notices, nvm is working as expected, as far as I can tell.

I posted this first in #855

What did you expect to happen?

No output in my terminal

Is there anything in any of your profile files that modifies the PATH?

I use Zimfw, but I otherwise don't do anything specific.

@ljharb
Copy link
Member

ljharb commented Nov 27, 2020

Duplicate of #2360.

@ljharb ljharb closed this as completed Nov 27, 2020
@Xananax
Copy link
Author

Xananax commented Nov 28, 2020

I had seen that other issue, but no one mentions parsing a markdown file and extracting env variables from there, so I'm thinking my issue might be two issues. Are you sure it's a duplicate?

@ljharb
Copy link
Member

ljharb commented Nov 28, 2020

I’m pretty confident - but I’ll reopen it just in case, and ping you when v0.7.2 is released.

@ljharb ljharb reopened this Nov 28, 2020
@ljharb ljharb closed this as completed in 3b57dfe Nov 28, 2020
@ljharb
Copy link
Member

ljharb commented Nov 28, 2020

I've gone ahead and reverted #2347, which will be released shortly as v0.7.2. Hopefully that solves the problem.

@ljharb
Copy link
Member

ljharb commented Nov 28, 2020

v0.7.2 is released. Please file a new issue if there's still problems.

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

No branches or pull requests

2 participants