Why can't I see the previous command with the up and down key? - pipenv

Why can't I see the previous command with the up and down keys when using the terminal in a virtual environment using pyenv and pipenv?

Related

Where to set the GOOGLE_APPLICATION_CREDENTIALS environment variable?

I am trying to use Python to call a Google Cloud AI platform training API. The path to my service account key JSON file is "/Users/my_mac_username/service_account_key.json", and I added the export statement in the bash_profile file so that it looks like:
# Setting PATH for Python 3.8
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH
export GOOGLE_APPLICATION_CREDENTIALS="/Users/my_mac_username/service_account_key.json"
However, I still got the error:
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials.
Besides, I have google-cloud-sdk folder installed. I would like to know in which file I should set the environment variable. Thanks for your help!
Assuming your terminal shell is bash, you have your environment variable setup correctly. The new variable will not be available until you reopen the terminal or run source ~/.bash_profile in the current terminal.
If you are running zsh, add the export in your ~/.zshrc file.
To determine which shell you're currently running, use: echo $SHELL from the command line

"bash: aws: command not found" on Windows 7 in Git Bash

I'm trying to use AWS CLI to access CodeCommit. And it's sort of working. I am able to use the aws command in the Windows command prompt. However, when I try to access it using the Git Bash shell, it says
"bash: aws: command not found."
Additionally, when I try to do do a git clone in the Windows command promt, trying to access CodeCommit, it tries to use aws using the credentials helper, which also results in "aws: command not found."
I followed the instructions in the AWS documentation, which suggests some directories to add to the PATH:
https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-windows.html#awscli-install-windows-path
Here's what my PATH variable looks like:
C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\;C:\Windows\System32;;C:\Program
Files\Docker
Toolbox;C:\Users\ddrayton\MyCurl;%USERPROFILE%\AppData\Local\Programs\Python\Python36\Scripts;C:\Program
Files\Amazon\AWSCLI;C:\Program Files
(x86)\Amazon\AWSCLI;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\Scripts
But I'm not sure if it's a PATH problem, since the Windows command prompt has no problem accessing the "aws" command.
Any ideas?
Fixed this by simply installing the AWS CLI again but this time using Git Bash instead of the Windows command prompt.
pip install awscli
If anyone could provide some insight as to why this was necessary, it would be appreciated.
In my case, I think a recent-to-me update to the AWS CLI changed what's run to being aws.cmd (full path C:\Program Files\Amazon\AWSCLI\bin\aws.cmd)
Git Bash needs the extension aws.cmd to make it work.
In Bash, you could try typing aws.cmd vs aws. If the former works, but not the latter, you can do alias aws='aws.cmd' in your bash startup script. I don't know if it's the best solution, but it worked for me.
FWIW, I think it's related to this:
https://unix.stackexchange.com/questions/280528/is-there-a-unix-equivalent-of-the-windows-environment-variable-pathext
On Windows 10 I was installing just once from GitBash via pip install awscli --upgrade --user as described in AWS manual for CLI installation for Linux
It installed aws executables into %USERPROFILE%\AppData\Roaming\Python\Python37\Scripts
After that just add this folder to your PATH. Re-open GitBash or cmd - it should work from both places

rails s command does not run from ssh

I am using Putty to connect to my localhost, and I don't have any problems apparently, however, when I run command rails s to start my rails 4.0.0 application from Putty, it gives me this message:
jose#jose-laptop:~/rails/dedicated-agenda$ rails s
The program 'rails' can be found in the following packages:
ruby-railties-3.2
ruby-railties-4.0
Try: sudo apt-get install
I don't get that message from the terminal though, the application starts running just fine.
I had to reinstall ubuntu so I upgraded to ubuntu 14.04 just in case you need to know.
I don't know if I am missing something in my ssh settings or how could I use rails s from Putty.
Thanks in advance.
Your PATH environment variable is set differently when you are executing programs in an interactive shell and by ssh(using putty).
Use absolute path of the program to not depend on the PATH variable.
You can also set the right PATH variable at ~/.profile file and load the updated variables using the command source ~/.profile.
Now, you should be able to run the command.
You can use the command
>which rails
to see where rails is installed on your working session.
Then you need to make sure that is in your path when you ssh in.
If you are ssh'ing in as a different use then that user may not have permission to see the rails executable.

postgres 'psql' command is not recognized in windows environment

It seems like I have it set up, I have my database.yml using postgres, and I can connect the database with pgadmin III, but when I tried using the psql command to test what version, it says that is is not recognized? Any idea what I should be doing?
I'm using windows and using command prompt with Ruby on Rails. Using PostgreSQL 9.2 installed with the EnterpriseDB one-click installer.
Assuming you installed PostgreSQL on Windows with the PostgreSQL "One-click" installer packaged by EnterpriseDB, psql is not added to the PATH automatically. That's partly because adding it to the path could otherwise cause confusion when people have multiple versions of PostgreSQL installed.
You need to specify the full explicit path to psql, eg:
"%PROGRAMFILES%\Postgresql\9.2\bin\psql.exe"
or add psql to the user PATH environment variable, see eg this guide.
Open Command Line
psql --version
if on above line psql version is not displayed, then follow below steps
(For Windows 7 OS)
Mycomputer->Properties->Advanced System Settings->EnvironmentVariables->Path->Edit->
(Donot remove any existing Path)
Add this
;C:\Program Files\PostgreSQL\9.5\bin;C:\Program Files\PostgreSQL\9.5\lib
save it then
Reopen Command Prompt and repeat
psql --version
C:\Users\rumi>psql --version
psql (PostgreSQL) 9.5.0
it is because there should not be space between the ; and your psql path so it should be like *****;C:\Program Files\PostgreSQL\9.2\bin\.
If there is a space after ******; then it will not work. You can actually type %PATH%in your cmd prompt and see how your environment variable and space looks like. I tried both cases for you, the first with space had the same error you mentioned and the second without space worked.
You need to set both the bin AND the lib path in your PATH environment variable separated by semicolons:
%PROGRAMFILES%\Postgresql\9.2\bin;%PROGRAMFILES%\Postgresql\9.2\lib

How to run Ruby and GIT commands in one place on Windows

I have Ruby and GIT installed on my windows box. To run GIT commands I am utilizing the GIT Bash. To run Ruby commands I am using the command line.
I have not been successful running GIT commands from the CMD line nor can I seem to run Ruby commands from inside the GIT Bash. I would love to be able to run commands for both GIT and Ruby from the GIT Bash (ideal) or at the least from the CMD line.
What is the best way to go about this?
I run git commands from the CMD session all the time.
Make sure your PATH environment variable includes the 'cmd' directory from a msysgit distro:
Path=C:\Path\To\Git\1.7.1\cmd
If not, add it in your session:
set PATH=%PATH%;C:\Path\To\Git\1.7.1\cmd
and you are done. Git and Ruby commands in your CMD shell.
The reverse (Ruby commands) is possible in a Git bash, by adding to the PATH a value like /c/path/to/Ruby/186-27/bin
To elaborate on VonC's answer of making Ruby available in Git-Bash.
All you have to do is add the path to your Ruby bin folder in your windows environment variables. It doesn't have to be in the format /c/path/to/ruby, it can be C:\Ruby193\bin.
Step by step for Windows 7:
Start
Search programs and files (default textbox after hitting the Start icon), Search for 'environment'
Select 'edit the system environment variables'
Click 'Environment Variables' (bottom right of the form)
Add to the 'System Variables' 'PATH' the following ';C:\Ruby193\bin' (without the single quotes)
Restart your shell
Make sure to close your git-bash shell and restart it to pick up the new environment variable.
Go to My Computer -> Properties -> Advanced system settings ->
Environment Variables
Add a New System variable. Variable name = RUBY_BIN. Variable
value = C:\Ruby193\bin (path may vary).
Add a New System variable. Variable name = MSYSGIT_BIN. Variable
value = C:\msysgit\bin (path may vary).
Append ;%RUBY_BIN%;%MSYSGIT_BIN% to Path variable, under System variables.
Restart shell.
This will allow you to run ruby, git or sh (Git Bash) commands from Command Prompt, as well as Ruby from Git Bash.
My personal setup uses msysgit and tortoisegit. I've found that using TortoiseGit's Pageant manager for the keys lets me use everything from any command line, including powershell. The only annoyance is I have to have pageant running with the keys added, which seem to clear on every reboot. Fortunately I don't reboot often.
The combined answer for VonC and Rots helped me to achieve the desired results.
However, since I was not familiar with editing environment variables, I must have accidentally overwritten the path for my nodejs files.
As a result my solution included adding the ruby path and the nodejs path to my user variables instead of the system.
I'm using a Windows 7 machine.
while installing ruby installer, select the option "Add ruby executables to your path" . Then all git/ruby commands will run from git bash.

Resources