Powershell: Add-WindowsFeature by pointing script to feature list - powershell

Is there a way to point to a windows feature list in a script or run a PowerShell command where I would point to a file that contains a list of windows features? for those who use python, i'm inspired by the pip install -r requirements.txt method where the requirements.txt just contains a list of packages.

Related

powershell and conda: conda activate env returns command not found

I have pip installed powerline-shell in my base conda env. Switching envs yields the following error:
conda activate <env_name>
-bash: powerline-shell: command not found
I also tried running conda init powershell but it took no actions.
I have miniconda3, with conda 4.7, installed on MacOS Mojave.
I don't know a simple solution to this. I'm thinking you either need to install it in every env (which I don't recommend because it's best to avoid using pip in Conda) or you create a link to the powerline-shell binary in another location that you can keep on PATH to avoid adding the entire miniconda3/bin/ directory to PATH. I've done something like this in the past, but never with a Python entry point before.
I'd try something like
mkdir -p ~/.local/bin
ln -s /your/path/to/miniconda3/bin/powerline-shell ~/.local/bin/powerline-shell
Then add .local/bin to PATH in your .bashrc, probably toward the beginning (e.g., before the Conda section). The path here (~/.local/bin) is totally arbitrary, so adjust to your preferences. Main point is to minimize what you are exposing globally in a shell session.
Note: conda init powershell is for Windows PowerShell users.

npm install -g generates the wrong script

This is a follow up this previous question related to how to install and run a javascript node.js command line tool.
According to this enter link description here you must execute npm install -g from within the folder of your project in order to be installed as a global command line tool executable from prompt.
When I run this instruction a .cmd file is created inside de global npm folder. But its content is wrong:
#"%~dp0\node_modules\lb-model-discovery\index.js" %*
I must manually change this content for it to be executed (otherwise I just get notepad being opened...) My question why npm install -g does not produced the right script in my system?
The solution is found in this github issue.
Basically the entry script (index.js) must contain this line at the top:
#!/usr/bin/env node

How to install nano using GitBash in Windows 10?

I am trying to install nano editor. From all the previous posts, I am stuck on path. What is path? How do I fix put my path?
I have:
$ mv nano ~/path/to/git/share
$ nano abc
bash: nano: command not found
You can add it via chocolatey.
choco install nano
PATH is the environment variable which is used to locate an executable you want to run.
See "How to permanently set $PATH on Linux?": you can add the folder where nano is in your .bashrc (which you can create directly under %USERPROFILE%, used by Git bash as $HOME)
Add to ~/.bashrc:
export PATH=$PATH:~/path/to/git/share
Then type
source ~/.bashrc
If you don't want to add it to your PATH, you can follow this step-by-step procedure, which does include the installation of nano-git-0d9a7347243.exe.
If your ultimate goal is to have and use nano on Windows 10, you can download the nano installer from here and just install the .msi file the usual Windows way. No manual path configurations required.

Installing with PIP in virtualenv?

I'm trying to wrap my head around virtualenv and pip still.
If I use pip to install a library, it doesn't matter where I 'cd' to, because it installs the libraries in the same place right (which i dont even know where that is)? So I guess my question is, when I install something with pip, how do I make sure it only installs that library inside of my virtual environment? Do I need to cd to that directory first? or is there a command I'm supposed to use with pip to make sure it only installs to the virtualenv project I'm working in?
Activate virtualenv first:
source virt_name/bin/activate
Then after that, install the libraries:
pip install module_name
Note: Don't use sudo with pip because sometimes it will assume you want to install in /usr/local/lib/site-packages.
Generally speaking, if you do not use virtualenv --system-site-packages to create your virtualenv, you should be only working with your per-environment packages.
Providing you run the activate script before installing anything.
i.e. Do the following, if you want to install something in your virtualenv.
Run activate script
Windows: [ve_directory]\Script\activate.bat
Linux: source [ve_directory]/bin/activate
pip install [your requirements]
I think it doesn't matter where your current working directory is.
Reference:
http://www.virtualenv.org/en/latest/#the-system-site-packages-option
When you create a new environment with virtualenv, among other things it creates a bash script venv/bin/activate (where venv is the folder you specified when you created the environment; libraries are located there as well, by the way). When you run it in your shell the environment variables become arranged so that pip installs new libraries in this environment's folder. See virtualenv docs for details, section "activate script".

Can't unzip Chef cookbooks on Windows Command Line - 'tar' not recognized

Unfortunately stuck using Windows command line as opposed to Linux bash...
When installing chef cookbooks from command line using
knife cookbook site install COOKBOOK
the COOKBOOK.tar.gz file will download but won't extract. How can I make this happen in Windows Command line?
The error messages received
ERROR: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
...
STDERR: 'tar' is not recognized as an internal or external command, operable program or batch file
What do I need to do for the cookbook to automatically install as it normally should?
EDIT: ADDITIONAL INFO: cygwin & ruby are also installed.
The tar package is installed and can unzip files using
tar xvzf apt.tar.gz
If you have git windows installed then use the git bash shell
The problem is with the PATH variable in Windows.
Ensure the PATH environment variable doesn't contain any spaces.
If there are spaces, remove them OR
move the paths applicable to your chef installation to the beginning of the PATH variable
D:\Programs\Git\cmd;D:\Programs\cygwin\bin;D:\Programs\chef\bin;RESTOFPATH