Export of PATH not permanent - linux

I'm using this command to export the path to use some packages I installed globally.
export PATH=~/.composer/vendor/bin:$PATH
the problem is whenever I restart my machine, I would still need to export it again.
Is there a way to make this export permanent?

Yes, many a times that's the problem with doing export PATH.
You should append the environment variable directly into your .bash_profile file! This will be permanent and solve your purpose,thereby, making your package used globally without any further problem with the package's path.
Append the following to the end of your .bash_profile file,and replace the ~ with the actual path,i.e., /home/user_name :-
PATH=/home/user_name/.composer/vendor/bin:$PATH
export PATH

Add this line to your ~/.bash_profile:
export PATH=$HOME/.composer/vendor/bin:$PATH

Related

EMCC not found - only works in emsdk not globally in terminal

I am a new Linux user and am looking to get the emscripten emcc command to work globally on Ubuntu.
This is my current configuration:
LLVM_ROOT = '/home/mpaccione/Projects/emsdk/upstream/bin'
BINARYEN_ROOT = '/home/mpaccione/Projects/emsdk/upstream'
EMSCRIPTEN_ROOT = '/home/mpaccione/Projects/emsdk/upstream/emscripten'
NODE_JS = '/home/mpaccione/Projects/emsdk/node/12.9.1_64bit/bin/node'
TEMP_DIR = '/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]
If I am in /var/www/html/collision-detection-wasm/hello-world
... command 'emcc' not found.
I followed the install instructions but they did not work how I would expect. I need this to work globally or it's not of use.
How do I go about doing that on Ubuntu Linux?
In order to use emcc it needs to be in your $PATH.
To do this you can run source /path/to/emsdk/emsdk_env.sh in your terminal.
Or if you want to make it permanent you can add that same command to your startup scripts (e.g. $HOME/.bash_profile or $HOME/.bashrc).
This is documented at https://emscripten.org/docs/getting_started/downloads.html.
Hijacking #sbc100's answer to further clarify things to answer OP's question asked as a comment.
In order to use emcc one needs to set the PATH and other environment variables.
As it can be seen in the documentation, the command source ./emsdk_env.sh (or source /path/to/emsdk/emsdk_env.sh if you are not within the emsdk directory) does exactly that for the current terminal.
If you want this effect to be permanent, then do just as #sbc100's said. Just add it to, for example, to your bashrc file by inserting source /path/to/emsdk/emsdk_env.sh to a new line at the end. This will make the script run each time a terminal opens. This may be annoying to same as it outputs what was added to PATH and which environment variables were set.
Alternatively, one may also add the entries to the bashrc manually that the script kindly tells us about. For me, it meant inserting the following lines:
## Emscripten ########
export PATH="/home/dudly01/repos/github/emsdk:$PATH"
export PATH="/home/dudly01/repos/github/emsdk/upstream/emscripten:$PATH"
export PATH="/home/dudly01/repos/github/emsdk/node/14.18.2_64bit/bin:$PATH"
export EMSDK="/home/dudly01/repos/github/emsdk"
export EM_CONFIG="/home/dudly01/repos/github/emsdk/.emscripten"
export EMSDK_NODE="/home/dudly01/repos/github/emsdk/node/14.18.2_64bit/bin/node"
I would think, however, that these lines need to be adjusted as the project evolves.

Add express to Path in NodeJS

Hi im working on NodeJS with express in Mac OS,
After install:
with brew: https://changelog.com/posts/install-node-js-with-homebrew-on-os-x
Shows me:
/Users/dortiz/.npm-packages/bin/express -> /Users/dortiz/.npm-packages/lib/node_modules/express-generator/bin/express-cli.js
And if I will execute:
daortiz:~ dortiz$ express
-bash: express: command not found
But:
/Users/dortiz/.npm-packages/bin/express
Its working,
Im trying to export a path with
export PATH=$PATH:/Users/dortiz/.npm-packages/bin/
Its success, but if I close and reopen the terminal don't works command
But doesn't works, any one know what I doing wrong?
Using export sets environment variables for current shell only. Once shell is terminated environment variables for that shell no longer exist.
In order to set environment variables for all shell that are initiated you should put them in ~/.bash_profile as pointed by mailo.
You need to add the line to a file that will be sourced on login, for example: ~/.bash_profile

my fedora PATH variables went out, how to restore them

I wanted to add php to envirmonment variables
So I wrote:
export PATH=/opt/lampp/bin/
Then I discovered that this was wrong because it relaced the envirmonment variable PATH with only ( /opt/lampp/bin/ ).
Is there a way to restore the path to an earlier version?
restart your shell / exit your terminal. unless you edit your .bashrc file the changes to environment variable via the export command are not permanent

Add laravel to path (Linux Mint 18.2 sonya)

I'm trying to use the shortcut "laravel new site" on bash but i got "laravel: command not found".
I already installed laravel by composer, and tried like 5 different ways to add this to PATH.
I added:
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
On the last line of bashrc, rebooted, still not working.
From the laravel installation documentation
Make sure to place the $HOME/.composer/vendor/bin directory (or the equivalent directory for your OS) in your $PATH so the laravel executable can be located by your system.
So, instead of
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
try
export PATH="$PATH:$HOME/.composer/vendor/bin"
When you edit .bashrc file, run command source ~/.bashrc to reload changes

.bash_profile conflicting with .profile preventing node from running

I have my ruby environment set up in .bash_profile and MacPorts installed in .profile, as per its instructions. I've installed node using MacPorts, but it seems like there's a conflict between .bash_profile and .profile. Node worked upon installation, but it hasn't worked since unless I delete .bash_profile or load .profile in the terminal.
I'm still new to setting up environments, so I'm not sure if I can essentially combine .bash_profile and .profile to avoid this conflict or if there's a better solution.
You can move the modifications MacPorts requires to $PATH wherever you want. If that fixes the issue, move them to .bash_profile.
Take a look at the value of $PATH when your setup works vs. when it doesn't. I assume whatever ruby environment you are using is changing it in some way. Adding the following line at the end of your .bash_profile should make it work again:
export PATH=/opt/local/bin:$PATH

Resources