システム:Linux Mint 20(Ubuntu)
だから、私はC / C ++用のwasmコンパイラemscriptenをインストールしましたが、bashrcにパスを追加すると、常に新しいターミナルシェルが起動され、パスが追加され、ターミナルのユーザーカラーが変更されたことがわかります。
これにより、この問題を解決でき、source ~/.bashrc
通常の色が戻ります。しかし、ここで正確に何が起こっているのか、そして可能な解決策があるのか知りたいのです。
以下は、どのように見えるかを示すいくつかのスクリーンショットです。
どんな洞察力やアドバイスでも大変感謝します!
編集する表示するファイルは次のとおりです。
.bashrc:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm|xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
if [[ ${EUID} == 0 ]] ; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] '
fi
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h \w \$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
if [ -x /usr/bin/mint-fortune ]; then
/usr/bin/mint-fortune
fi
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
alias paper='. /home/doom/Desktop/Minecraft/Paper/paper'
export PATH=$PATH:"$USER/QT/5.15.1/gcc_64/bin"
export PATH=$PATH:"$HOME/doom/Desktop/RoseDevelopment/emsdk"
export PATH=$PATH:"$HOME/doom/Desktop/RoseDevelopment/emsdk/node/12.18.1_64bit/bin"
export PATH=$PATH:"$HOME/doom/Desktop/RoseDevelopment/emsdk/upstream/emscripten"
source "/etc/profile.d/rvm.sh"
alias startPg='~/pgAdmin4/venv/bin/python ~/pgAdmin4/venv/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py'
そして/etc/bash.bashrc:
# System-wide .bashrc file for interactive bash(1) shells.
# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, overwrite the one in /etc/profile)
# but only if not SUDOing and have SUDO_PS1 set; then assume smart user.
if ! [ -n "${SUDO_USER}" -a -n "${SUDO_PS1}" ]; then
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
# ;;
#*)
# ;;
#esac
# enable bash completion in interactive shells
#if ! shopt -oq posix; then
# if [ -f /usr/share/bash-completion/bash_completion ]; then
# . /usr/share/bash-completion/bash_completion
# elif [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
# fi
#fi
# sudo hint
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
case " $(groups) " in *\ admin\ *|*\ sudo\ *)
if [ -x /usr/bin/sudo ]; then
cat <<-EOF
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
EOF
fi
esac
fi
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not found\n" "$1" >&2
return 127
fi
}
fi
編集#2: nvmコマンドで始まる行だけを実行しようとすると、次のようになります。
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
このコマンドラインの後に# This loads nvm
nvmコマンドが機能します。
私のyarn
コマンドは以前は動作しませんでしたが、実行後は動作しました。
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
次の場合でも、Minecraft Paper Serverコマンドは機能しません。
alias paper='. /home/doom/Desktop/Minecraft/Paper/paper'
ただし、このemcc
コマンドは次の行を試みる前後に機能します。
export PATH=$PATH:"$HOME/doom/Desktop/RoseDevelopment/emsdk"
export PATH=$PATH:"$HOME/doom/Desktop/RoseDevelopment/emsdk/node/12.18.1_64bit/bin"
export PATH=$PATH:"$HOME/doom/Desktop/RoseDevelopment/emsdk/upstream/emscripten"
このstartPg
コマンドは以前は機能しませんでしたが、次のように入力すると機能します。
alias startPg='~/pgAdmin4/venv/bin/python ~/pgAdmin4/venv/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py'
これらのコマンドはすべて実行した後に機能します。source ~/.bashrc
編集#3 それで興味深い結果を得ました。ここにbashrcファイルがあります。
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
echo 'am i here?'
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm|xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
if [[ ${EUID} == 0 ]] ; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] '
fi
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h \w \$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
if [ -x /usr/bin/mint-fortune ]; then
/usr/bin/mint-fortune
fi
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
alias paper='. /home/doom/Desktop/Minecraft/Paper/paper'
export PATH=$PATH:"$USER/QT/5.15.1/gcc_64/bin"
echo 'hello world'
export PATH=$PATH:"$HOME/doom/Desktop/RoseDevelopment/emsdk"
export PATH=$PATH:"$HOME/doom/Desktop/RoseDevelopment/emsdk/node/12.18.1_64bit/bin"
export PATH=$PATH:"$HOME/doom/Desktop/RoseDevelopment/emsdk/upstream/emscripten"
echo 'hi'
# source "/etc/profile.d/rvm.sh"
alias startPg='~/pgAdmin4/venv/bin/python ~/pgAdmin4/venv/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py'
rvmをコメントアウトしました。そうする前と後でもまだ動作していましたが、source ~/.bashrc
私の考えでは、rvmをインストールすると、私が信じるコマンドにアクセスできるrvmグループに入るためだと思います。
emsdk(emcc)パスの上と下のエコーは、私が実行するまで印刷されずにsource ~/.bashrc
実行されます。また、ファイルの一番上にエコーを置き、ファイルソースを実行するまで実行されません。
次のようになります。
編集#4 申し訳ありません。内容が長すぎますが、このファイルが問題を引き起こしているかどうか疑問に思います。
.bash_config ファイル
source "/home/doom/Desktop/RoseDevelopment/emsdk/emsdk_env.sh"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
rvm 行と emsdk_env.sh 行にコメントを付けると、エコーは消えます。rvm
コマンドは引き続き機能しますが、emcc コマンドは機能しなくなります。これを行うまで、まだカラー出力は出ておらず、他のほとんどsource ~/.bashrc
のコマンドnvm/yarn/paper/startPgが再び機能します。
これにより、私の.bashrcファイルが新しいセッションからロードされないように見えますか?
視聴する:
doom@doom-MacBookPro:~$ rvm
# It works here
doom@doom-MacBookPro:~$ yarn
-bash: yarn: command not found
doom@doom-MacBookPro:~$ rvm list
#This works here
doom@doom-MacBookPro:~$ emcc
-bash: emcc: command not found
doom@doom-MacBookPro:~$ paper
-bash: paper: command not found
doom@doom-MacBookPro:~$ nvm
-bash: nvm: command not found
doom@doom-MacBookPro:~$ source ~/.bashrc
am i here?
hello world
hi
doom@doom-MacBookPro ~ $ nvm
#This works here
doom@doom-MacBookPro ~ $ paper
#This works here
doom@doom-MacBookPro ~ $ yarn
#This works here
ベストアンサー1
まあ、私はついにそれを見つけたでしょう。私の質問の下のコメントで判断します。ところで、@Criggieと@msbに感謝します。
run as command login shell
@user3584014がこの質問に対する2回目の回答で行った操作に従うと、端末の設定でリセットすることもできます。https://askubuntu.com/questions/161249/bashrc-not-executed-when-opening-new-terminal
https://askubuntu.com/a/768359/1138077
これはそれをよく要約します:
In my case, simply the .bashrc loader lines were missing in .bash_profile
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
I added it manually and it worked with my fresh login
これにより、emccを含むすべてのコマンドが機能し、最初から色が復元されます。
Adding directories to PATH:
PATH += /home/doom/Desktop/RoseDevelopment/emsdk
PATH += /home/doom/Desktop/RoseDevelopment/emsdk/upstream/emscripten
PATH += /home/doom/Desktop/RoseDevelopment/emsdk/node/12.18.1_64bit/bin
Setting environment variables:
EMSDK = /home/doom/Desktop/RoseDevelopment/emsdk
EM_CONFIG = /home/doom/Desktop/RoseDevelopment/emsdk/.emscripten
EM_CACHE = /home/doom/Desktop/RoseDevelopment/emsdk/upstream/emscripten/cache
EMSDK_NODE = /home/doom/Desktop/RoseDevelopment/emsdk/node/12.18.1_64bit/bin/node
doom@doom-MacBookPro ~ $ emcc
emcc: error: no input files
doom@doom-MacBookPro ~ $ yarn -v
1.22.10
doom@doom-MacBookPro ~ $ rvm -v
Warning! PATH is not properly set up, /home/doom/.rvm/gems/ruby-2.5.3/bin is not at first place.
Usually this is caused by shell initialization files. Search for PATH=... entries.
You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
To fix it temporarily in this shell session run: rvm use ruby-2.5.3
To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
rvm 1.29.10 (manual) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
doom@doom-MacBookPro ~ $ nvm -v
0.36.0
doom@doom-MacBookPro ~ $
emcc コマンドでまだエコーが発生します。
.bash_profile:
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
source "/home/doom/Desktop/RoseDevelopment/emsdk/emsdk_env.sh"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
しかし、他のすべてが最初から正しく機能する限り、これはそれほど大きな問題ではありません。複数の端末を開いてタスクを実行し、常にそのタスクを実行する必要があるのはsource ~/.bashrc
本当に痛いからです。