I'm using the github codespace to test the Discord.js bot. In it, I used the command fortune | owsay
and used the fortune
and cowsay
commands. The fortune command was installed using sudo apt install Fortune-mod
. cowsay Use <代码>sudo apt to install cowsay代码>. Their installation directory is under "/usr/games" instead of "/bin", so when I run the command fortune |Niu said
I understand
bash: fortune: command not found bash: cowsay: command not found
This is because /usr/games is not in $PATH in the Github code space
When I add "/usr/games" to the path in "/etc/profile" and "~/.profile", use
export PATH="/usr/games:$PATH"
Place at the bottom of both files, then use the command "source /etc/profile" and later test "source ~/.profile" these commands Works... but when I try to run the file using VScode's built-in runner (press f5 and click node.js), it automatically creates a new shell and uses node to run the file that is not found by its command.
I'm wondering how GitHub codespaces can create a new shell without the new path I added. And how to add the /usr/games
directory to the path of the new shell that opens when vscode runs the file
Although the shells you use in Github Codespace are interactive, they are not login shells. Only the login shell runs the
/etc/profile
and~/.profile
files.You can test whether the shell is a login shell by running the following command:
you can:
PATH
in.bashrc
files etc.; interactive non-login files will run this file. Although I don't think it's best practice to setPATH
in a file other than.profile
.bash -l
to start a new shell as the login shell..vscode-remote
settings.json
file - go toSettings
andRemote [Codespaces]
, clicking theEdit in settings.json
button should get you here, then add the new profile toterminal.integrated.profiles.linux
...Then open a new terminal in VS Code using the
bash (login)
profile.