Git bash export function not recognized or without an effect - environment-variables

I am using git-bash on windows, but unfortunately it seems I have a configuration issue. I am trying to use the export function to set environment variables, like so:
$ export php='/c/xampp/php/php.exe'
$ php -v
bash: php: command not found
This is also the case after a restart of git-bash.
Using the alias function works:
$ alias php='/c/xampp/php/php.exe'
$ php -v
PHP 7.4.7 (cli) (built: Jun 9 2020 13:36:15) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
I've also tried to register the environment variables directly in the .bash_profile-configuration-file, which I assume is the one located under C:/Users/username, but that does not work either.
As of now, I assume if haven't setup git correctly or made some stupid mistake. Any hint what I am missing would be very much appreciated.

Variables are referenced with $, and you don’t need to export them unless you want them to become environment variables of spawned programs.
php=/c/xampp/php/php.exe
$php -v
You should continue using alias for this, though – that’s what it’s for! – or extend your $PATH instead:
PATH="$PATH:/c/xampp/php"

Related

Ghostscript installed but not found RGhost::Config::GS[:path]='/path/to/my/gs'

I've been trying for a few hours now solve this problem and I looked everywhere for a solution and I did not find one. I'm trying to run a spec test for my project and I have the following error coming up:
RuntimeError:
Ghostscript not found in your system environment (linux-gnu).
Install it and set the variable RGhost::Config::GS[:path] with the executable.
Example: RGhost::Config::GS[:path]='/path/to/my/gs' #unix-style
RGhost::Config::GS[:path]="C:\\gs\\bin\\gswin32c.exe" #windows-style
And I do try to put RGhost::Config::GS[:path]='/usr/local/bin/gs' and it returns:
bash: RGhost::Config::GS[:path]=/usr/local/bin/gs: No such file or directory
but ghostscript is installed, I did everything (make, sudo make install, etc etc) and when I run gs -v it returns:
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
When I use the user interface and search for "gs" in the "Files" application, it is found in /home/marcelle/projects/ghostscript-9.26/bin/gs and I also tried:
RGhost::Config::GS[:path]='/home/marcelle/projects/ghostscript-9.26/bin/gs'
and it returns the same error:
bash: RGhost::Config::GS[:path]=/home/marcelle/projects/ghostscript-9.26/bin/gs: No such file or directory
I also tried to delete ghostscript from my notebook with autoremove and purge and installed it again using what I mentioned before (./configure, make, sudo make install), restarted the notebook, the terminal and nothing.
PS: I'm using Ubuntu 20.04.
I managed to figure out a solution. Looking for the code for the Rghost, what I saw in its spec is that the path expected was different than the path the ghostscript really is.
When I run whereis or which on my terminal, it returns:
which gs
/usr/local/bin/gs
So I was trying to point to this path. But seeing the spec test for Rghost which I found on github for Rghost, we can see that it expects /usr/bin/gs:
it 'should detect linux env properly' do
RbConfig::CONFIG.should_receive(:[]).twice.with('host_os').and_return('linux')
File.should_receive(:exists?).with('/usr/bin/gs').and_return(true)
RGhost::Config.config_platform
RGhost::Config::GS[:path].should == '/usr/bin/gs'
end
So it expects /usr/bin and not /usr/local/bin.
Then I just copied to that path and the spec ran with no problems anymore:
sudo cp /usr/local/bin/gs /usr/bin
I've no experience with Ruby at all, but I also got this error when using asciidoctor, which uses rghost for the PDF generation.
The command RGhost::Config::GS[:path]='/path/to/my/gs' mentioned in the error is not a shell command, which is why bash couldn't handle it. However, to me it wasn't immediately clear what to do with this command either. I expected an easy way to set this variable somewhere, but couldn't find it.
What worked for me was searching the rghost.rb file, which is where this variable is set and can be changed. In Windows, it was located in C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\rghost-0.9.7\lib\rghost.rb.
In this file, I added the following line, which solved the problem:
RGhost::Config::GS[:path]="C:\\Program Files\\gs\\gs9.55.0\\bin\\gswin64c.exe"
NB: the mentioned paths can be different for everyone, so make sure to use that paths that are valid for your system.

Lua on git bash doesn't work, works on CMD windows

So I'm trying to use lua on Windows.
I've installed with the LUA Windows Installer and ended up trying on git bash but the command lua isn't recognized.
I've tested on my CMD since my environment variable are set and it works on CMD.
Can't seem to make it work on Git Bash.
I took the binaries available at the time (5.3.5) and put everything in a 5.3.5 folder inside my Lua folder.
Renamed lua53 in lua. Changed my PATH environnement variable to be
And voilà

Alpine not loading /etc/profile [duplicate]

I'm trying to write (what I thought would be) a simple bash script that will:
run virtualenv to create a new environment at $1
activate the virtual environment
do some more stuff (install django, add django-admin.py to the virtualenv's path, etc.)
Step 1 works quite well, but I can't seem to activate the virtualenv. For those not familiar with virtualenv, it creates an activate file that activates the virtual environment. From the CLI, you run it using source
source $env_name/bin/activate
Where $env_name, obviously, is the name of the dir that the virtual env is installed in.
In my script, after creating the virtual environment, I store the path to the activate script like this:
activate="`pwd`/$ENV_NAME/bin/activate"
But when I call source "$activate", I get this:
/home/clawlor/bin/scripts/djangoenv: 20: source: not found
I know that $activate contains the correct path to the activate script, in fact I even test that a file is there before I call source. But source itself can't seem to find it. I've also tried running all of the steps manually in the CLI, where everything works fine.
In my research I found this script, which is similar to what I want but is also doing a lot of other things that I don't need, like storing all of the virtual environments in a ~/.virtualenv directory (or whatever is in $WORKON_HOME). But it seems to me that he is creating the path to activate, and calling source "$activate" in basically the same way I am.
Here is the script in its entirety:
#!/bin/sh
PYTHON_PATH=~/bin/python-2.6.1/bin/python
if [ $# = 1 ]
then
ENV_NAME="$1"
virtualenv -p $PYTHON_PATH --no-site-packages $ENV_NAME
activate="`pwd`/$ENV_NAME/bin/activate"
if [ ! -f "$activate" ]
then
echo "ERROR: activate not found at $activate"
return 1
fi
source "$activate"
else
echo 'Usage: djangoenv ENV_NAME'
fi
DISCLAIMER: My bash script-fu is pretty weak. I'm fairly comfortable at the CLI, but there may well be some extremely stupid reason this isn't working.
If you're writing a bash script, call it by name:
#!/bin/bash
/bin/sh is not guaranteed to be bash. This caused a ton of broken scripts in Ubuntu some years ago (IIRC).
The source builtin works just fine in bash; but you might as well just use dot like Norman suggested.
In the POSIX standard, which /bin/sh is supposed to respect, the command is . (a single dot), not source. The source command is a csh-ism that has been pulled into bash.
Try
. $env_name/bin/activate
Or if you must have non-POSIX bash-isms in your code, use #!/bin/bash.
In Ubuntu if you execute the script with sh scriptname.sh you get this problem.
Try executing the script with ./scriptname.sh instead.
best to add the full path of the file you intend to source.
eg
source ./.env instead of source .env
or source /var/www/html/site1/.env

How make luaenv and luarocks play together correctly

Me using anyenv for installing all scripting languages versions. Currently using it for perl plenv, node ndenv, python pyenv and just installed the luaenv too. Great, because doesn't pollute the system dirs - everything is installed to my user defined directory.
The luaenv is installed OK, and i could:
$ luaenv install 5.1.5 #installed OK
$ luaenv global 5.1.5 #OK
$ luaenv which lua
/opt/anyenv/envs/luaenv/versions/5.1.5/bin/lua
$ luaenv versions
* 5.1.5 (set by /opt/anyenv/envs/luaenv/version)
$ lua -v
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
Looks that everything is OK.
Of course want install luarocks too. Unfortunatey, the luaenv itself doesn't provides support for the installtion of the luarocks, (e.g. missing the luaenv install-rocks or something like for the perl: plenv install-cpanm) - so tried follow the quick-start guide, e.g.:
download the sources
./configure
make build
The configure failed with the message about the missing lua.h.
Checking Lua includes...
lua.h not found (looked in /opt/anyenv/envs/luaenv/include, /opt/anyenv/envs/luaenv/include/lua/5.1, /opt/anyenv/envs/luaenv/include/lua5.1)
You may want to use the flag --with-lua or --with-lua-include. See --help.
So, the first bug: the luaenv isn't sets the correct paths. :(
After the:
$ find /opt/anyenv/envs/luaenv -name lua.h -print
/opt/anyenv/envs/luaenv/versions/5.1.5/include/lua.h
tried again with:
$ ./configure --with-lua=/opt/anyenv/envs/luaenv/versions/5.1.5
Now it finishes successfully, so followed with the make build.
Checked the result, of the build in the src/luarocks/site_config.lua
local site_config = {}
site_config.LUAROCKS_PREFIX=[[/usr/local]]
site_config.LUA_INCDIR=[[/opt/anyenv/envs/luaenv/versions/5.1.5/include]]
site_config.LUA_LIBDIR=[[/opt/anyenv/envs/luaenv/versions/5.1.5/lib]]
site_config.LUA_BINDIR=[[/opt/anyenv/envs/luaenv/versions/5.1.5/bin]]
site_config.LUAROCKS_SYSCONFDIR=[[/usr/local/etc/luarocks]]
site_config.LUAROCKS_ROCKS_TREE=[[/usr/local]]
site_config.LUAROCKS_ROCKS_SUBDIR=[[/lib/luarocks/rocks]]
site_config.LUA_DIR_SET=true
site_config.LUAROCKS_UNAME_S=[[Darwin]]
site_config.LUAROCKS_UNAME_M=[[x86_64]]
site_config.LUAROCKS_DOWNLOADER=[[curl]]
site_config.LUAROCKS_MD5CHECKER=[[md5sum]]
return site_config
Which is clearly WRONG. The paths shold NOT point to the /usr/local but somewhere into the versioned directories managed by the luaenv.
I'm an lua-noob. Trying to learn it. But i'm unable to set even the basic environment. :( After a hour of googling giving up and asking here:
How to configure and install luarocks to play correctly with the luaenv and the lua versions installed by the luaenv?

Ejabberd installation strange issue

OS: Debian 8.1 X64
trying to install eJabberd Community server based on this tutorial
At the end of installation, it pops error message
Error: Error running Post Install Script.
The installation may have not completed correctly
What am I doing wrong?
It looks like /bin/sh is Dash on your system (apparently the default since Debian Squeeze). However, the postinstall.sh script inside the package uses brace expansion, which while widely supported in various shells is not required by the POSIX standard, and thus Dash is not in error by not supporting it. The postinstall.sh script should either specify /bin/bash instead of /bin/sh in its first line, or abstain from using Bash-specific features.
You should be able to get a functioning ejabberd install by explicitly running the postinstall script with Bash:
sudo bash /opt/ejabberd-15.07/bin/postinstall.sh

Resources