Suggested command to eval "docker-machine env default" output fails on Cygwin - linux

I am currently working on this: https://mozilla.github.io/ichnaea/install/devel.html#prerequisites and have been a bit stuck since they recommend working with Linux/Mac but I am limited to Windows. I tried getting their steps to work with Git Bash, Powershell, and Command Prompt but to no success. I am currently trying Cygwin to see if it would work however I am running into some issues. I currently run docker-machine env default and see the output:
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="..."
export DOCKER_CERT_PATH="..."
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Run this command to configure your shell:
# eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default)
When I attempt to run the command to configure the shell, eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env default), I get an error saying: -bash: C:\Program Files\Docker Toolbox\docker-machine.exe: command not found.
This is different than Git Bash, Powershell, and CMD since when I ran the respective commands on those shells there were no issues at all and it led me to successfully move on to the next steps. Is there any reason why I am getting this command not found error on Cygwin, and what should I do to fix it?
Thanks for reading

Adding a cygpath invocation to convert the executable path:
eval "$("$(cygpath -u "C:\Program Files\Docker Toolbox\docker-machine.exe")" env default)"

Related

pipenv shell working but an error is displayed

If I run the command:
pipenv shell
in my Mac shell, everything works fine and a new virtual environment is created and activated:
.../django_celery_rabbit_flower$ pipenv shell
Launching subshell in virtual environment...
bash: parse_git_branch: command not found
.../django_celery_rabbit_flower$ . /.../django_celery_rabbit_flower-rEt8HW1V/bin/activate
bash: parse_git_branch: command not found
(django_celery_rabbit_flower) .../django_celery_rabbit_flower$
but a bash error is displayed:
bash: parse_git_branch: command not found
I do not understand where it come from. Any idea?
UPDATE
Jen answer trigger a little thought. I have checked my ./bash_profile and I can see the line:
export PS1="\[\033[36m\]\u\[\033[m\]#\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$(parse_git_branch)\$ "
This shows the git branch on the bash prompt. So I believe vscode uses this settings. The folder I am working on is not a git folder. Can I write an if statement to avoid the error being displayed when running the python virtual environment?
Instead make sure that the command does actually exists before running it.
PS1="...."'$(if hash parse_git_branch >/dev/null 2>&1; then parse_git_branch; fi)'"..."

How to change WebStorm enviroment settings for File Watcher?

I have simple File Watcher that run TSLint. If I copy the command and run it in the console all fine but WebStorm run it with old Node version and throw error Buffer.alloc is not a function.
I'm using nvm to manage node.js versions.
ubuntu 16.4
Different Node.js versions are on your $PATH when you start your script from the IDE and from terminal.
When being launched from desktop/System menu, WebStorm only sees environment variables configured in login shell, but not in interactive shell configuration files (like .bashrc or .zshrc).
Possible workarounds:
Workaround 1: make required variables available in a login shell by moving them to the corresponding shell profile config
Workaround 2: run IDE from a terminal, either with the command line launcher or with bin/webstorm.sh
Workaround 3: edit the desktop launcher and set command to /path/to/shell -l -i -c "/path/to/webstorm.sh" (make sure that the shell you specified there has the needed variables configured in its interactive shell configuration file)
see also https://youtrack.jetbrains.com/issue/IDEABKL-7589

Activate virtualenv using alias

I can activate my python virtual environment from it's folder by entering . bin/activate. I'd like to instead type a single word alias, such as shazam, from the home folder (or anywhere else) that activates the environment, changes to my master project folder, and lists my projects.
I tried creating an alias in .bashrc that pointed to an .sh file containing:
cd ~/path-to-virtual-environment
. bin/activate
cd ~/path-to-master-project-folder
ls -a
I was getting a permission denied error, so I ran chmod u+x <script file>. The script now runs, but the VE does not activate and while the project folders are listed, the shell is not in the master project folder. I would appreciate some guidance. Thanks.
Recreate all your environments in ~/.virtualenvs and install virtualenvwrapper. The command to activate an env is workon shazam. Command line completion is supported.
Now about your problem: you've tried to activate an environment in a shell script. That doesn't work because shell scripts run with another shell and env activation change their environments, not the current. I.e., the environment briefly activated but then at the end of the script the new shell exits and the environment deactivated.
There are two ways to overcome this.
Use aliases or shell functions instead of scripts — they are the only way to change the current shell's environment.
Run interactive shell at the end of your script (exec $SHELL). It inherits activated environment and gives you a command prompt. To deactivate simply exit the shell (exit or [Ctrl]+[D].).

Specify which shell Yarn uses for running scripts

My package.json has a script in it like this:
"buildTslint": "node_modules/typescript/bin/tsc node_modules/awesomeLibrary_node_tslint/{,helpers/}*.ts",
Note the {,helpers/}*.ts part, this is called Brace Expansion and is only possible in bash, not sh.
When running yarn buildTslint I get the following output:
# yarn buildTslint
yarn buildTslint v0.22.0
$ node_modules/typescript/bin/tsc node_modules/awesomeLibrary_node_tslint/{,helpers/}*.ts
error TS6053: File 'node_modules/awesomeLibrary_node_tslint/{,helpers/}*.ts' not found.
error Command failed with exit code 2.
It seems that Yarn uses sh to execute these scripts, but I'd like to use bash for this, to be able to use brace expansion.
yarn version 1.19 added support for a new config parameter script-shell. You can now do the following:
yarn config set script-shell /bin/bash
It may launch the command using system function see also man 3 system.
To see which system call is used :
strace yarn ...
system uses fork+exec+wait and the exec family functions uses shell /bin/sh
to use bash the command can be changed to bash -c 'command ..'
Yarn doesn't yet provide a way to configure the default shell used for running scripts, see: https://github.com/yarnpkg/yarn/issues/4248
However, since yarn uses Node for spawning its processes, you can work around that by changing the default shell that Node itself uses.
On Ubuntu, if you have root permissions, you can do this by changing the symlink /bin/sh to point to something other than dash:
sudo ln -sf /bin/bash /bin/sh
In Git-bash in Windows, you can change the COMSPEC environment variable to something other than C:\Windows\system32\cmd.exe, but I haven't gotten that to work for me.
See also:
Force node to use git bash on windows

CDH4 JAVA_HOME Ubuntu

I have installed CDH4 in pseudo distributed mode on CentOs without any problems, but when I am installing it on Ubuntu 12.04 I am getting some errors with setting my JAVA_HOME environment variable.
I installed JDK and and have JAVA_HOME set correctly in /etc/profile.d and in ~/bash.rc using the following lines:
export JAVA_HOME=/usr/local/java/latest
export PATH=${JAVA_HOME}/bin:$PATH
I know that is redundant to define it in both places, but apparently setting it in /etc/profile.d wasn't working. From my user, when I type $echo $JAVA_HOME I get:
/usr/local/java/latest
From sudo, I run $ sudo -E echo $JAVA_HOME, I get:
/usr/local/java/latest
If you are wondering, I am specifying the -E option for sudo to preserver my environment.
So my real problem is when I am trying to start HDFS, using the following command:
for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x start ; done
I get the following error:
* Starting Hadoop datanode:
Error: JAVA_HOME is not set and could not be found.
Running the same command with the -E option gives me the same result. Has anyone had this problem?
Thanks in advance.
After some research, I found the answer to my question.
I am using CDH4 and have hadoop installed in pseudo-distributed mode.
To fix my JAVA_HOME problems, I created a the hadoop-env.sh file in /etc/hadoop/conf.pseudo.mr1
The file contained the line:
export JAVA_HOME=/usr/local/java/latest
Where /usr/local/java/latest is the path to my installation of JAVA_HOME

Resources