Some info I don't want hard-code, so os.Setenv() is not what I want.
What I've tried:
CMD: go env -w newVar=myVal
GOT: go env -w: unknown go command variable newVar
Windows, add Environment variables (both System and User), then restart Goland
GOT: nothing
Any other solution?
UPDATE:
IT WORKS: RESTART COMPUTER (Windows 10)
people use "tricks" like a .env file or a config.toml or.... any file that holds the values. They make a copy of that like .env_default or config-default.toml. Then in the .gitignore ignore the good ones. And the copies are filled with examples.
So when an other colleague gets everything, there's no real secret in there because that didn't get committed. They can read in the readme what to do with the "default one" and voila...
Related
The company I work for has a code repository deep within a folder structure, the path of which I have saved in a text file. As I was copying that path from notepad++ and pasting it into a cd command for the hundredth time after launching git bash I began to get the feeling that I was wasting time. Being the good programmer that I am, spending an hour researching how to do something programmatically is obviously preferable to doing something that takes four seconds over and over again. However I have been disappointed to find that all of the readily-available solutions offer one of two recommendations which both feel more like workarounds than an actual config change:
Create a shortcut and modify the "start in" field. This is not acceptable for me because I launch git from the start menu (windows key + type "git"). I don't want to add the extra steps of navigating to the folder where I created the shortcut. Even if I give the shortcut a unique name such as "stupidshortcutname", I am not able to access this shortcut by searching in the windows start menu.
Modify the Windows environment variable HOME. This is not acceptable because I still want cmd to launch in its default location of C:\Users\MyUserNameHere.
With some further research I also found the option of creating a file called .bashrc in my C:\Users\MyUserNameHere directory, and having this run cd <folder I want to go to>, but this still feels pretty hacky for something that I feel should be a configuration somewhere.
Git has its own config files, I would be shocked if none of them allowed for setting the location git will default to launching in. Am I out of luck and/or being too picky?
Create a batch file with name like LaunchGit.bat & write the following command:
start F:\Program" "Files\Git\git-bash.exe --cd=D:\your\deep\workspace\path
Now you can launch it from desktop or place it in your Git home directory (and launch from there)
This may not be the most perfect solution, but it will solve your problem.
And ofCouse this is just an idea and you can change/improve it.
Use git-bash configuration to change the directory, if this is what you want.
In ~/.bash_profile (create it if it does not exist), add
cd /path/to/git/repository
The reason to use ~/.bash_profile instead of ~/.bashrc is because the latter is read and executed when an interactive shell that is not a login shell is started (if exists).
If I try to run virtualenv, I get this message:
$ virtualenv
-bash: /Users/me/Library/Python/3.6/bin/virtualenv: No such file or directory
It's not surprising that this happens, because I've removed this directories at an earlier point when trying to clean up my computer from different Python versions. However, how does my system know to look in that directory for virtualenv? I've looked in my bash profile, and there is no mention of virtualenv there.
When you type something your command interpreter has to search the command. Of course it cannot try every possible directory on your system. Then it provides to the user a way to control that process. This is the purpose of the PATH environment variable :
$ echo $PATH
will show you the actual value which looks like dir1:dir2:...:dirn, meaning that commands where searched for in dir1, then dir2, etc. You have to remove the value /Users/me/Library/Python/3.6/bin/ from it. The best way is to edit the .bashrc or .bash_profile file to remove the permanent setting of this variable. Then reconnect.
I must put all the files GO creates inside the structure of GO, not scattered. While changing GOPATH and GOROOT, I noticed the build folder on ~/.cache/go-build.
This SO thread didn't help at all, not either the article it links. It doesn't seems to deal directly with that. How can I change it?
Edit: the problem isn't how to find the GOCACHE, which I already know that can be viewed by go env GOCACHE, but how can I change that folder.
I've tried to add to ~/ .bashrc:
export GOCACHE=$HOME/path/to/folder, and now when I use go env GOCACHE, it points to the new folder but still tries to send files to ~/.cache/go-build. The log file is now returning the following error:
go: disabling cache (/home/<me>/.cache/go-build) due to initialization failure: mkdir /home/<me>/.cache/go-build: permission denied
The error shown
go: disabling cache (/home/<me>/.cache/go-build) due to initialization failure: mkdir /home/<me>/.cache/go-build: permission denied
Is because the directory /home/<me>/.cache/go-build does not exist and permissions to create a new directory aren't there. This shouldn't happen, it seems like some unknown factor in your build process is clobbering the GOCACHE settings
Do you literally have a user called <me>? That's quite unusual and ill advised, as <> are shell meta characters
As for setting the path, see https://github.com/golang/go/blob/master/src/cmd/go/internal/cache/default.go
and https://golang.org/pkg/os/#UserCacheDir
If GOCACHE env variable is set then it uses that. If not it uses os.UserCacheDir which is usually $HOME/.cache but can be overridden, see the docs
The simple answer is to set the GOCACHE env variable to be inside your Go containment area
Just to clarify. Go compiler and tools run inside another environment.
This other environment has variables set inside it, which Go will honour
On Linux systems, this environment is usually the bash shell. In the bash shell to set the GOPATH the command "export GOPATH=$HOME/go" is often used, to set up a GOPATH to a folder called go in the home directory of the current user. To set the GOCACHE set the variable in the environment you are using and Go will pick it up
cd $HOME
sudo chown -R <yourname>.<yourname> .cache/go-build
It works for me.
I was having the same issue, using a Mac.
I solved it by unlocking the folder, see prints below
The first one is a sign in Finder showing the folder is locked
And the second is where to unlock folder
I am running this command under windows 7:
git status
Now I am getting this error:
fatal: unable to access 'H:\/.config/git/config
I am disconnected from the network at the moment. Can I still fix this by changing the config location or creating a new config?
Can I still fix this by changing the config location or creating a new config?
You can simply change your environment variable HOME, in order to reference an existing local folder
set HOME=C:\local\path
In that folder, a .gitconfig can be defined in order to have a global git config file.
The msysgit/msysgit/git-cmd.bat defines it by default to:
#if not exist "%HOME%" #set HOME=%USERPROFILE%
Git will respect the HOME environment variable to determine the location of the global .gitconfig.
If asking your domain admin to reset your HOMEDRIVE and HOMEPATH variable back to your local user profile is not an option, you can simply change the HOME variable instead (which is usually unset, so there won’t be a conflict) at the top of your shell to make Git use that location.
For example, if you’re using Git Bash, you can simply add the following line to the bottom of your shell profile, located at C:\Program Files (x86)\Git\etc\profile:
export HOME="$USERPROFILE"
(I think $USERPROFILE is still left to the default even if the domain settings change your home drive. Of course, you can always specify a fixed path if that doesn’t work)
If you are using other shells, you can do similar things, for example in PowerShell:
$env:HOME = $env:USERPROFILE # or = 'C:\Users\poke\'
Of course, since the variable is unset by default, you could also set it at Windows level in your system configuration. That way, every program would use it automatically.
Afterwards, all Git commands will automatically look at $HOME\.gitconfig.
You need to specify the config file location using git config and the -f option.
git config -f your_config_file
I'm on a Mac and I'm trying to make a Vim plugin for compiling/running actionscript files.
First, I need to run mxmlc on the command line, but to do that I have to keep on typing the path to it. Where do I place it so that I don't have to retype the path?
You need to modify your "$PATH" environment variable, so that the tool is in that directory. However, if you want to make this very easy... you can download my macosx-environment-setup.tar.bz2 program. If you execute the "install.sh" script using "sudo ./install.sh", it will setup your environment in such a way that if you use "/Library/Flex4SDK" as the location for the Flex4SDK, it will automatically find it, define FLEX_HOME to point to that location, and it will also ensure that the binaries from the Flex4SDK are in your PATH.
Side Note: This is up on the web, because I use it in my Development Environment Setup How-To Guides. If you aren't too keen about running "sudo ./install.sh", you need to choose a location (I am going to assume "/Library/Flex4SDK", so that the tools are located in "/Library/Flex4SDK/bin"), and then you would simply need to edit your "~/.profile" file (using "nano ~/.profile"), adding the following to the very end:
export FLEX_HOME=/Library/Flex4SDK
export PATH="$PATH":"$FLEX_HOME/bin"
Note that these changes occur in your shell... they will not affect programs that are launched by double-clicking them in Finder. In order to affect those programs, you will need to place the environment variables in a file named ~/.MacOSX/environment.plist. See Automatically build ~/.MacOSX/environment.plist for a script that will automatically generate such a file using the current environment variables defined in your shell.
There are a few ways to answer this:
In one of your directories searched
by PATH (see the list with echo
$PATH)
Add a new directory to PATH
(e.g. in your ~/.bashrc
export PATH=$PATH:/path/to/bindir)
Add an
alias to your program (e.g. in your
~/.bashrc alias
mxmic=/path/to/mxmic)
(I'm assuming you're using bash shell, which is usually the case you can check with echo $SHELL)