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

[bug] "npm create tauri-app" fails on openSUSE Tumbleweed with "Not a directory" error #193

Closed
ancwrd1 opened this issue Sep 28, 2022 · 10 comments

Comments

@ancwrd1
Copy link

ancwrd1 commented Sep 28, 2022

Describe the bug

Trying to create a project under openSUSE Tumbleweed with npm create tauri-app, it fails with the following error:

error: Not a directory (os error 20)
npm ERR! code 1
npm ERR! path /tmp
npm ERR! command failed
npm ERR! command sh -c -- create-tauri-app

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/x/.npm/_logs/2022-09-28T16_53_00_647Z-debug-0.log

Same error with any other tool (e.g. yarn).

Reproduction

No response

Expected behavior

No response

Platform and versions

Environment
  › OS: openSUSE 20220926 X64
  › Node.js: 18.9.1
  › npm: 8.19.1
  › pnpm: Not installed!
  › yarn: 1.22.19
  › rustup: 1.25.1
  › rustc: 1.64.0
  › cargo: 1.64.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu 

Stack trace

No response

Additional context

I tried running it with strace utility and the syscall which fails is:

openat(AT_FDCWD, "/usr/bin/node18", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOTDIR (Not a directory)

Node.js installation contains two executables: /usr/bin/node (which seems to be a stub) and /usr/bin/node18 (the real one).
If I rename /usr/bin/node18 to /usr/bin/node then everything works.

This issue is specific to tauri, I tried for example creating other apps like react and it worked.

@FabianLars FabianLars transferred this issue from tauri-apps/tauri Sep 28, 2022
@amrbashir
Copy link
Member

can you upload the full log here?

@ancwrd1
Copy link
Author

ancwrd1 commented Sep 28, 2022

Sure but I think it's not very helpful. Here is it:
2022-09-28T16_53_00_647Z-debug-0.log

@ancwrd1
Copy link
Author

ancwrd1 commented Sep 28, 2022

Might be an issue with this line in the create-tauri-app.js:

if (binStem === "node" || binStem === "nodejs") {
   ...
}

@amrbashir
Copy link
Member

the logs shows that it fails to invoke create-tauri-app, can you try running inside a directory that isn't /tmp preferably $HOME

Might be an issue with this line in the create-tauri-app.js:

if (binStem === "node" || binStem === "nodejs") {
   ...
}

Nah this is just used to provide a better name for the cli in the help message

@ancwrd1
Copy link
Author

ancwrd1 commented Sep 28, 2022

I tried that already, the current directory doesn't really matter.
The difference is the nodejs executable name, if it's /usr/bin/node it works, if it's /usr/bin/node18 (invoked by /usr/bin/node) then there is this "not a directory" error.

@amrbashir
Copy link
Member

are you using any node manager like nvm or fnm?

@ancwrd1
Copy link
Author

ancwrd1 commented Sep 28, 2022

No, just installed node.js from the Linux repositories.

But it uses libalternatives method to launch a specific node version, so I can have version 18 and 17 installed at the same time.

The /usr/bin/node stub reads /usr/share/libalternatives/node/18.conf file which looks like:

binary=/usr/bin/node18
man=node18.1

Then it execs this binary replacing itself (execve call).

@ancwrd1
Copy link
Author

ancwrd1 commented Sep 28, 2022

It's actually pretty simple to reproduce under Linux:

  • Rename /usr/bin/node to /usr/bin/node18
  • Create /usr/bin/node shell script with the following context:
#!/bin/bash
exec /usr/bin/node18 "$@"
  • Mark it as executable with chmod +x /usr/bin/node

@amrbashir
Copy link
Member

based on your last reproduction comment, I have this output:

amr - ~ took 4s 
❯ yarn create tauri-app
yarn create v1.22.17
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Installed "create-tauri-app@2.5.0" with binaries:
      - create-tauri-app
[####] 4/4
+✔ Package name · usrbinnode185
error: Not a directory (os error 20)
error Command failed.
Exit code: 1
Command: /home/amr/.yarn/bin/create-tauri-app
Arguments: 
Directory: /home/amr
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

amr - ~ took 23s 
❯                      

You can see the highlighting comment is asking for Package name pre-filled with userbinnode18. this step only happens when a path has been provided to the cli.

So somehow the cli is invoked like this create-tauri-app /usr/bin/node18 so create-tauri-app will use that first argument as a directory to initialize the project in which doesn't exist because it is a file.

Now I don't know why this happens but this seems like an issue with the script which I don't have knowledge/time to debug.

I am using nvm and fnm to manage multiple node versions and they both work fine so maybe libalternative has a bug.

@amrbashir amrbashir closed this as not planned Won't fix, can't repro, duplicate, stale Oct 3, 2022
@ancwrd1
Copy link
Author

ancwrd1 commented Oct 4, 2022

It's not related to libalternative, I have mentioned above that you can reproduce it simply by making a shell script wrapper called /usr/bin/node which calls /usr/bin/node18.

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

2 participants