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

failed to detect scriptname on read only file system #49

Closed
contrun opened this issue Feb 18, 2019 · 2 comments
Closed

failed to detect scriptname on read only file system #49

contrun opened this issue Feb 18, 2019 · 2 comments

Comments

@contrun
Copy link
Contributor

contrun commented Feb 18, 2019

The function os.scriptname uses rename to detect if a file exists. Rename will always fail on my nixos machine as the executable lies in a read only file system. Here is the log after adding print(name, ok, err, code) to the function os.path.exists. Actually file /nix/store/99p0nyqgayic2ipqx2x4lr4njl8f5nrz-python3-3.6.8/bin/realpath do exist.

 lua ~/.z.lua/z.lua --init zsh                                                                                              ~
/nix/store/99p0nyqgayic2ipqx2x4lr4njl8f5nrz-python3-3.6.8/bin/realpath  nil     Read-only file system   30
/home/e/bin/realpath    nil     No such file or directory       2
/run/wrappers/bin/realpath      nil     No such file or directory       2
/home/e/.bin/realpath   nil     No such file or directory       2
/home/e/.bin/realpath   nil     No such file or directory       2
/home/e/.local/bin/realpath     nil     No such file or directory       2
/home/e/.cabal/bin/realpath     nil     No such file or directory       2
/home/e/.cargo/bin/realpath     nil     No such file or directory       2
/home/e/Local/go/bin/realpath   nil     No such file or directory       2
/home/e/.node/node_modules/.bin/realpath        nil     No such file or directory       2
/usr/local/bin/realpath nil     No such file or directory       2
/usr/bin/realpath       nil     No such file or directory       2
/bin/realpath   nil     No such file or directory       2
/home/e/.nix-profile/bin/realpath       nil     Read-only file system   30
/nix/var/nix/profiles/default/bin/realpath      nil     No such file or directory       2
/run/current-system/sw/bin/realpath     nil     Read-only file system   30
/etc/profiles/per-user/e/bin/realpath   nil     No such file or directory       2
/nix/store/99p0nyqgayic2ipqx2x4lr4njl8f5nrz-python3-3.6.8/bin/perl      nil     Read-only file system   30
/home/e/bin/perl        nil     No such file or directory       2
/run/wrappers/bin/perl  nil     No such file or directory       2
/home/e/.bin/perl       nil     No such file or directory       2
/home/e/.bin/perl       nil     No such file or directory       2
/home/e/.local/bin/perl nil     No such file or directory       2
/home/e/.cabal/bin/perl nil     No such file or directory       2
/home/e/.cargo/bin/perl nil     No such file or directory       2
/home/e/Local/go/bin/perl       nil     No such file or directory       2
/home/e/.node/node_modules/.bin/perl    nil     No such file or directory       2
/usr/local/bin/perl     nil     No such file or directory       2
/usr/bin/perl   nil     No such file or directory       2
/bin/perl       nil     No such file or directory       2
/home/e/.nix-profile/bin/perl   nil     Read-only file system   30
/nix/var/nix/profiles/default/bin/perl  nil     No such file or directory       2
/run/current-system/sw/bin/perl nil     Read-only file system   30
/etc/profiles/per-user/e/bin/perl       nil     No such file or directory       2
/nix/store/99p0nyqgayic2ipqx2x4lr4njl8f5nrz-python3-3.6.8/bin/python    nil     Read-only file system   30
/home/e/bin/python      nil     No such file or directory       2
/run/wrappers/bin/python        nil     No such file or directory       2
/home/e/.bin/python     nil     No such file or directory       2
/home/e/.bin/python     nil     No such file or directory       2
/home/e/.local/bin/python       nil     No such file or directory       2
/home/e/.cabal/bin/python       nil     No such file or directory       2
/home/e/.cargo/bin/python       nil     No such file or directory       2
/home/e/Local/go/bin/python     nil     No such file or directory       2
/home/e/.node/node_modules/.bin/python  nil     No such file or directory       2
/usr/local/bin/python   nil     No such file or directory       2
/usr/bin/python nil     No such file or directory       2
/bin/python     nil     No such file or directory       2
/home/e/.nix-profile/bin/python nil     Read-only file system   30
/nix/var/nix/profiles/default/bin/python        nil     No such file or directory       2
/run/current-system/sw/bin/python       nil     Read-only file system   30
/etc/profiles/per-user/e/bin/python     nil     No such file or directory       2
/nix/store/99p0nyqgayic2ipqx2x4lr4njl8f5nrz-python3-3.6.8/bin/python2   nil     Read-only file system   30
/home/e/bin/python2     nil     No such file or directory       2
/run/wrappers/bin/python2       nil     No such file or directory       2
/home/e/.bin/python2    nil     No such file or directory       2
/home/e/.bin/python2    nil     No such file or directory       2
/home/e/.local/bin/python2      nil     No such file or directory       2
/home/e/.cabal/bin/python2      nil     No such file or directory       2
/home/e/.cargo/bin/python2      nil     No such file or directory       2
/home/e/Local/go/bin/python2    nil     No such file or directory       2
/home/e/.node/node_modules/.bin/python2 nil     No such file or directory       2
/usr/local/bin/python2  nil     No such file or directory       2
/usr/bin/python2        nil     No such file or directory       2
/bin/python2    nil     No such file or directory       2
/home/e/.nix-profile/bin/python2        nil     Read-only file system   30
/nix/var/nix/profiles/default/bin/python2       nil     No such file or directory       2
/run/current-system/sw/bin/python2      nil     Read-only file system   30
/etc/profiles/per-user/e/bin/python2    nil     No such file or directory       2
/nix/store/99p0nyqgayic2ipqx2x4lr4njl8f5nrz-python3-3.6.8/bin/python3   nil     Read-only file system   30
/home/e/bin/python3     nil     No such file or directory       2
/run/wrappers/bin/python3       nil     No such file or directory       2
/home/e/.bin/python3    nil     No such file or directory       2
/home/e/.bin/python3    nil     No such file or directory       2
/home/e/.local/bin/python3      nil     No such file or directory       2
/home/e/.cabal/bin/python3      nil     No such file or directory       2
/home/e/.cargo/bin/python3      nil     No such file or directory       2
/home/e/Local/go/bin/python3    nil     No such file or directory       2
/home/e/.node/node_modules/.bin/python3 nil     No such file or directory       2
/usr/local/bin/python3  nil     No such file or directory       2
/usr/bin/python3        nil     No such file or directory       2
/bin/python3    nil     No such file or directory       2
/home/e/.nix-profile/bin/python3        nil     Read-only file system   30
/nix/var/nix/profiles/default/bin/python3       nil     No such file or directory       2
/run/current-system/sw/bin/python3      nil     Read-only file system   30
/etc/profiles/per-user/e/bin/python3    nil     No such file or directory       2
lua: /home/e/.z.lua/z.lua:1415: attempt to concatenate a nil value
stack traceback:
        /home/e/.z.lua/z.lua:1415: in function 'z_shell_init'
        /home/e/.z.lua/z.lua:1150: in function 'main'
        /home/e/.z.lua/z.lua:1696: in main chunk
        [C]: in ?
@skywind3000
Copy link
Owner

skywind3000 commented Feb 18, 2019

It's strange, os.path.exists works on my linux, it can return true for /usr/bin (current user doesn't have write permission on it).

So, I cannot reproduce your problem on my linux or freebsd servers.

Do you have any idea how to detect file existence on nixos ??

contrun added a commit to contrun/z.lua that referenced this issue Feb 18, 2019
@contrun
Copy link
Contributor Author

contrun commented Feb 18, 2019

I tried the method to check if a file exists provided on stackoverflow. This works on my nixos machine. Still, it may not work for files which the user has no read permission to the file and it is a read only file system.

contrun added a commit to contrun/z.lua that referenced this issue Feb 19, 2019
contrun added a commit to contrun/z.lua that referenced this issue Feb 19, 2019
contrun added a commit to contrun/z.lua that referenced this issue Feb 19, 2019
@contrun contrun closed this as completed Feb 19, 2019
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