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

bash setup #8

Closed
afreisinger opened this issue Sep 21, 2021 · 4 comments
Closed

bash setup #8

afreisinger opened this issue Sep 21, 2021 · 4 comments

Comments

@afreisinger
Copy link
Contributor

afreisinger commented Sep 21, 2021

Hi Carl !

Amazing dotfiles repository !

Hopefully you can guide me, since I can't find the solution. When I run on my mac with zsh by default, the command source ./.bashrc the script runs partially but in terminal it shows me
"node / 16.9.1
Use up / down arrow keys to select a version, return key to install, d to delete, q to quit "

I press return key or quit, but

cp: /usr/local/n/versions/node/16.9.1/lib/dtrace: unable to copy extended attributes to / usr / local / lib / dtrace: Bad file descriptor
cp: /usr/local/lib/dtrace/node.d: Permission denied
rm: /usr/local/lib/node_modules/npm/man/man5/npmrc.5: Permission denied
and much more

The script ends but I don't know what happened.
Another detail is the terminal prompt, it returns after executing any command successfully, -sh: __git_ps1: command not found

Thanks a lot !
Regards

Adrian

@fatso83
Copy link
Owner

fatso83 commented Sep 22, 2021

Whoa 😱 That does not sound so hot. I have just run the dotfiles setup on a fresh new M1 Macbook, and I think I did not do anything special (beside re-running it a few times, as not all utils are present on first run) and I definitely did not see any errors like that.

When I see stuff like Bad file descriptor I am immediately tempted to say "File system corruption", but the reason is probably something much less severe. As in, could the reason be something as basic as missing file permissions on /usr/local? I think that would explain most of your issues and it might be that I have just done that step without thinking about it.

This is how my own permissions look:

carlerik at carl-eriks-air in ~/dev/dotfiles (master)
$ ls -lh /usr/local
total 0
drwxr-xr-x  72 root      wheel   2,3K  1 aug 13:53 aws-cli
drwxr-xr-x  29 carlerik  wheel   928B  2 sep 10:29 bin
drwxr-xr-x   3 carlerik  wheel    96B 30 jul 00:15 include
drwxr-xr-x   5 carlerik  wheel   160B  1 aug 17:01 lib
drwxr-xr-x   5 root      wheel   160B 12 jul 12:01 libexec
drwxr-xr-x   3 carlerik  wheel    96B 30 jul 00:13 n
drwxr-xr-x   5 carlerik  wheel   160B 30 jul 00:15 share

carlerik at carl-eriks-air in ~/dev/dotfiles (master)
$ ls -lhd /usr/local
drwxr-xr-x  9 root  wheel   288B  2 aug 17:32 /usr/local

By default, /usr/local and all its subdirs are owned by root. Then all installations will fail to put anything in there, including stuff like n (the Node version chooser). I think Homebrew might change this when installing it, so either I used brew install <someapp> before running my dotfiles or I fixed the permissions myself.

I would try sudo chown -R $USER /usr/local/* and then re-run.

Regarding the bash prompt error: __git_ps1: command not found. This is caused by the $PS1 environment variable, which controls how the prompt should look like. It executes a command called __git_ps1, which needs to be present in your shell. This is supposed to be taken care of automatically ... so something is definitely not working on your setup.

So the commands are sourced from this file. It is being read at startup by bashrc. So I am pretty sure you should be seeing errors both during setup and when starting up, as it seems the files have not been copied over.

If you enter the dotfiles repo and run ./common-setup/setup.sh, what happens?

On my Macbook this is what happens:

carlerik at carl-eriks-air in ~/dev/dotfiles (master)
$ ./setup.sh
Installing common setup
Installing all VIM plugins(might take some time the first time ... )
Fetching rupa/z (Jump Around)
Finished common setup

Install config specific to this machine
Setting up local settings for this machine
Installing local apps using Homebrew ...
finished
 You might need to re-run the global setup as build tools might not have been available
Adding scripts and binary utilities
Requirement already satisfied: pip in /Users/carlerik/Library/Python/3.9/lib/python/site-packages (21.2.4)
Requirement already satisfied: smsutil in /Users/carlerik/Library/Python/3.9/lib/python/site-packages (1.1.3)
Requirement already satisfied: future>=0.16.0 in /Users/carlerik/Library/Python/3.9/lib/python/site-packages (from smsutil) (0.18.2)
Requirement already satisfied: requests in /Users/carlerik/Library/Python/3.9/lib/python/site-packages (2.26.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/carlerik/Library/Python/3.9/lib/python/site-packages (from requests) (1.26.6)
Requirement already satisfied: charset-normalizer~=2.0.0 in /Users/carlerik/Library/Python/3.9/lib/python/site-packages (from requests) (2.0.3)
Requirement already satisfied: certifi>=2017.4.17 in /Users/carlerik/Library/Python/3.9/lib/python/site-packages (from requests) (2021.5.30)
Requirement already satisfied: idna<4,>=2.5 in /Users/carlerik/Library/Python/3.9/lib/python/site-packages (from requests) (3.2)

@fatso83
Copy link
Owner

fatso83 commented Sep 22, 2021

The tips above was for debugging the installation, but when you have installed everything without errors, one way of debugging the Bash setup is to do DEBUG=1 source-rc. It will print out lots of info while reading the config

@afreisinger
Copy link
Contributor Author

Work form me !!!
sudo chown -R $USER /usr/local/* and then re-run
Thanks a lot !

@fatso83
Copy link
Owner

fatso83 commented Sep 23, 2021

This is not the most advanced dotfiles in the world and if you are using ZSH, then you can find lots of other dotfiles repos with much fancier setup, but I chose to use my own after trying ones I did not understand and that were basically too complicated for me, using features I did not want or did not know I wanted ...

The good thing about this setup is that it is very easy to understand and modify for your own needs (copying cool stuff from other places), and it is also easy to have a common base that works on a lot of operating systems (having the same utility functions and aliases), while allowing customizing for each platform independently. For instance, I love that I can do cat file | pbcopy to copy a file into my paste-buffer and know that it works on Windows, Mac and Linux. Hope you find something useful/interesting in here and you build your own custom thing on top :)

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