I want to run a go get command when GOPROXY='direct', I've tried to run this command using the VS code terminal:
GOPROXY='direct' go get go.mongodb.org/mongo-driver/mongo
but I'm getting this error:
GOPROXY=direct : The term 'GOPROXY=direct' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ GOPROXY='direct' go get go.mongodb.org/mongo-driver/mongo
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (GOPROXY=direct:String) [], CommandNotFoundEx
ception
+ FullyQualifiedErrorId : CommandNotFoundException
I've also tried:
go env set GOPROXY='direct'
but when I run go env command the GOPROXY value is still like this GOPROXY=https://proxy.golang.org,direct
and I also tried to define a GOPROXY variable in the windows environment variable and giving it the value of direct but it also failed to do the job.
Make sure your VSCode terminal is a bash one, not a CMD or Powershell.
In a CMD or Powershell, the syntax var=xxx cmd would not be correctly interpreted as: set a variable and execute a command inheriting its environment variables, including the one set.
Related
i can not call a In-Script Function without PowerShell ISE
When i call a function in the normal Powershell i get this Error
onboarding : The term "onboarding" was not used as the name of a cmdlet, function, script file, or
of an executable program. Check the spelling of the name or if the path is correct (if
included) and repeat the process.
In *************************************.ps1:8 characters:9
+ onboarding
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (onboarding:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Have in mind Mathias R. Jessen's useful comment (valid for ▶ button as well):
When you use F5 to run a script in ISE, it doesn't actually
invoke the script, it executes the contents of the editor in the
global scope of the attached console/runspace, so it'll persist after
the first attempt.
Run your script using Dot sourcing operator .
Runs a script in the current scope so that any functions, aliases, and
variables that the script creates are added to the current scope,
overriding existing ones. Parameters declared by the script become
variables. Parameters for which no value has been given become
variables with no value. However, the automatic variable $args is
preserved.
Example:
. c:\scripts\sample.ps1 1 2 -Also:3
Note. The dot sourcing operator is followed by a space. Use the space
to distinguish the dot from the dot (.) symbol that represents the
current directory.
I'm trying to (eventually) execute a ruby script via R by calling the shell() function. As a first step though, I am simply trying to verify that I can call the ruby compiler via this function, and I am getting an error. Here is my code:
dir <- shell("ruby -v", intern=TRUE)
This throws a warning: Warning message: running command
'C:\WINDOWS\system32\cmd.exe /c ruby -v' had status 1
And the 'dir' variable is blank. I have verified that the command "ruby -v" works when run in a command prompt, and that Ruby is included in my system path variables.
You need to confirm that the ruby path is within PATH environmental variable using Sys.getenv("PATH"). If it isn't, you can always add it as you stated above with Sys.setenv.
Here is a way to simply append the PATH variable with a new directory.
Sys.setenv(PATH = paste(Sys.getenv("PATH"), "/my/ruby/dir/bin", sep=":"))
I'm not aware of a more concise way to append a path to an existing environmental variable from within R.
I'm trying to get emacs to become a global name so I can reference it anywhere on my filesystem. This is what I did on the command line:
$PATH = C:/emacs/bin:$PATH
But when I do that I get the following error:
sh.exe": /c/home/bin:.:/usr/local/bin:/mingw/bin:/bin:/c/Program: No such file or directory
I even went directly to Start Menu->System [Properties]->Environment Variables and I tried to add C:\emacs\bin to the list of the paths but the name still came up as emacs: command not found. I don't know what I'm doing wrong.
Note that this is only a problem within C:\cygwin. Outside of that directory I can type emacs without a problem.
Your command
$PATH = C:/emacs/bin:$PATH
has several problems:
$ evaluates the variable, you need to set it
spaces are significant, you do not need them
you cannot use : inside a Cygwin path
Use this instead:
PATH=/c/emacs/bin:$PATH
I am trying to edit my .xinitrc file so that startx can run with a parameter telling it which window manager/desktop to use, but fall back to a default one if none are provided. .xinitrc is a shell script.
What I have used is this code:
desktop=${desktop:-startkde}
exec $desktop
The idea is that running startx desktop=fluxbox will launch a different desktop then the default provided, however this does not work. Can anyone see what I am doing wrong here?
Try:
desktop=fluxbox startx
Environment variables are set by putting them before the command name; everything after the command name is just arguments to the command.
I have installed cygwin and I am about to execute a script written in powershell. I do it like this:
powershell "& ""C:\my\script.ps1"""
This works as expected, I have to do this that way because in that script I am executing another external command and so on ...
I would like to add some environment variable to that script, so I would like to write something like
powershell "$FOO="bar"; & ""C:\my\script.ps1"""
so I can then access $FOO variable in the script and do something with it. The idea is that if that variable is not defined, I use some default value. I know that this could be also achieved with some environment variables or I could put these variables to the profile (profile.ps1) but I want to get rid of that file so I need none and I can override the default value with the variables as I showed.
but is says that:
=bar : The term '=bar' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
So I was thinking that something like this could work:
powershell { $web = "google.com" ; & ping.exe $web }
But it works only in powershell console and not in cygwin, it cygwin it says that
-bash: syntax error near unexpected token `&'
So it seems like that & is treaten as bash character. I tried to escape it in thousand ways, e.g.
bash -c "'powershell { \$web = \"google.com\" ; & ping.exe \$web }'"
But this is the output
bash: powershell { $web = "google.com" ; & ping.exe $web }: command not found
Thank you for a hint.
UPDATE
I am able to do this:
powershell "Invoke-Command -ScriptBlock {\$env:FOO = \"google.com\" ; & ""C:\my\script.ps1"" }"
But when I am trying to access that FOO variable throught $env:FOO it is empty, it seems like I am unable to do so because that script is running in another scope or what ...
this command will pass an environment variable from cygwin ($FOO="bar") to powershell, then run another powershell command (dir env:) which lists the environment variables (proving that it was set):
powershell "\$env:FOO=\"bar\";dir env:"
replace the dir env: part with your script call and this should work for you.
edit: here's the command (quoted slightly differently) including the call to an external script:
powershell '$env:FOO="bar";& "C:\script name.ps1"'