I need to create a fact in puppet to get which versions of .netcore are installed in the servers.
Facter.add('common_dotnetcore_version') do
confine :kernel => 'windows'
powershell = 'C:\Windows\system32\WindowsPowershell\v1.0\powershell.exe'
setcode do
dotnetVersion = Hash.new
if Facter::Util::Resolution.which('dotnet')
dotNetList = Facter::Core::Execution.exec(%Q{#{powershell} -command "(((dotnet --list-runtimes ) -replace '(?!\d*\.\d*)[A-Za-z([():\]\\)]') | select -Unique)"})
dotNetList.each_line { |line| dotnetVersion[line] = true }
end
dotnetVersion
end
end
please note that when I run this command in PowerShell
(((dotnet --list-runtimes ) -replace '(?!\d*\.\d*)[A-Za-z([():\]\\)]') | select -Unique)
I got this output:
.. 2.1.26 ..
.. 2.1.28 ..
.. 3.1.13 ..
.. 3.1.15 ..
.. 5.0.4 ..
.. 5.0.6 ..
But when its executed by Puppet I got this output:
Microsoft.AspNetCore.All 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
It's not doing the -replace with the Regex
Does anyone know why Puppet does not recognize the Regex and | select -Unique?
The problem is that backslashes inside a Ruby %Q{...} quoted string have a meaning. For example, %Q{\n} is a newline. So the backslashes in your regex are being interpreted by the %Q{...} string before they get to PowerShell.
If you look at the string:
puts %Q{'(?!\d*\.\d*)[A-Za-z([():\]\\)]'}
# '(?!d*.d*)[A-Za-z([():]\)]'
you'll see that the backslashes are going away.
The easiest thing to do is to escape all the backslashes by doubling them:
dotNetList = Facter::Core::Execution.exec(%Q{#{powershell} -command "(((dotnet --list-runtimes ) -replace '(?!\\d*\\.\\d*)[A-Za-z([():\\]\\\\)]') | select -Unique)"})
Related
I am currently using ruby version 2.7.0 and I want to upgrade to version 3.1.0 in ubuntu 20:04. I have installed ruby 3.1.0 by following Install ruby 3 using rbenv. This is my output of command rbenv versions, seems the installation is completed.
peisen#peisen:~$ rbenv versions
* system (set by /home/peisen/.rbenv/version)
3.1.0
However, when i check my ruby version using ruby -v
peisen#peisen:~$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
It shows the version is still 2.7.0. I am still a beginner in ubuntu and not sure how to modify this. I followed this post but this did not work for me. Any ideas?
The output
peisen#peisen:~$ rbenv versions
* system (set by /home/peisen/.rbenv/version)
3.1.0
means that you have two versions installed, system Ruby and 3.1.0. The asterisk indicates that system Ruby is still the currently selected version.
To switch to Ruby 3.1.0 globally run:
$ rbenv global 3.1.0
See the docs about rbenv global and other options to set your desired Ruby version.
I need to perform some preprocessing that depends on the latest versions of certain PyPI packages. For example: scipy version 1.8.0. This package version has been released on PyPI on February 5th 2022.
I'm trying to pip install this package on Google Colab via:
# Specifying the index explicitly to ensure we're using PyPI directly.
!pip install -i https://pypi.python.org/simple scipy==1.8.0
Unfortunately this errors with:
Looking in indexes: https://pypi.python.org/simple
ERROR: Could not find a version that satisfies the requirement scipy==1.8.0 (from versions: 0.8.0, 0.9.0, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.12.1, 0.13.0, 0.13.1, 0.13.2, 0.13.3, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 1.0.0b1, 1.0.0rc1, 1.0.0rc2, 1.0.0, 1.0.1, 1.1.0rc1, 1.1.0, 1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0rc1, 1.4.0rc2, 1.4.0, 1.4.1, 1.5.0rc1, 1.5.0rc2, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.6.0rc1, 1.6.0rc2, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.7.0rc1, 1.7.0rc2, 1.7.0, 1.7.1, 1.7.2, 1.7.3)
ERROR: No matching distribution found for scipy==1.8.0
Even though scipy 1.8.0 clearly is on the https://pypi.python.org/simple index, I'm not seeing it Colab, and the latest available version is several months old.
Is there a way to pip install up-to-date package versions on Colab?
If you look at the files here
https://pypi.org/project/scipy/1.8.0/#files
You'll see they are only available for Python 3.8 and above.
So You'll either need to upgrade Python to 3.8 or compile scipy 1.8.0 from source.
I want to install a recent version of Ruby on Ubuntu 20.04.
But when I run rbenv install -l on my Ubuntu server, I only see old versions of Ruby listed.
Available versions:
1.8.5-p52
...
2.2.7
2.3.0-dev
2.3.0-preview1
2.3.0-preview2
2.3.0
2.3.1
2.3.2
2.3.3
2.3.4
2.4.0-dev
2.4.0-preview1
2.4.0-preview2
2.4.0-preview3
2.4.0-rc1
2.4.0
2.4.1
2.5.0-dev
jruby-1.5.6
jruby-1.6.3
jruby-1.6.4
...
jruby-9.1.8.0
jruby-9.1.9.0-dev
jruby-9.1.9.0
jruby-9.1.10.0
jruby-9.1.11.0
jruby-9.1.12.0
maglev-1.0.0
maglev-1.1.0-dev
maglev-2.0.0-dev
mruby-dev
mruby-1.0.0
mruby-1.1.0
mruby-1.2.0
rbx-2.2.2
rbx-2.2.3
...
rbx-3.79
rbx-3.80
rbx-3.81
rbx-3.82
ree-1.8.7-2011.03
ree-1.8.7-2011.12
ree-1.8.7-2012.01
ree-1.8.7-2012.02
topaz-dev
Compared to when I run it locally on my mac, I see recent versions like 2.7.1.
2.5.8
2.6.6
2.7.1
...
Why don't these new version show on Ubuntu?
I have rbenv 1.1.1 installed on Ubuntu.
This is probably a dumb question but I have little understanding of code below the webdev level.
I ran this command and it solved my problem.
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Now I see recent versions of Ruby.
When I type bundle install, I get this message error:
sassc-2.0.0 requires ruby version >= 2.3.3, which is incompatible with the current version, ruby 2.3.0p0.
But I clean up my computer and there is no more version 2.3.0p0.
Here is the result of bundle env :
Environment
Bundler 1.17.2
Platforms ruby, x86_64-linux
Ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]
Full Path /usr/share/rvm/rubies/ruby-2.6.1/bin/ruby
Config Dir /usr/share/rvm/rubies/ruby-2.6.1/etc
RubyGems 3.0.1
Gem Home /usr/share/rvm/gems/ruby-2.6.1
Gem Path /usr/share/rvm/gems/ruby-2.6.1:/usr/share/rvm/gems/ruby-2.6.1#global
User Path /root/.gem/ruby/2.6.0
Bin Dir /usr/share/rvm/gems/ruby-2.6.1/bin
Tools
Git 2.7.4
RVM 1.29.7 (manual)
rbenv rbenv 0.4.0
chruby not installed
rubygems-bundler (1.4.5)
Bundler Build Metadata
Built At 2018-12-19
Git SHA 3fc4de72b
Released Version false
Thanks for your help.
It's exactly the same issue :
Trouble removing ruby 2.3.0p0 from Ubuntu
There is still a file ruby2.3 in usr/bin.
Hi there I am new to bower and would like to install the beta version of bourbon but get the latest stable version instead.
Command executed:
bower install thoughtbot/bourbon
and got:
bourbon#4.2.7 bower_components/bourbon
Looking at the bower.json in https://github.com/thoughtbot/bourbon I can see the version being "5.0.0-beta.7" which I would like to install. I am doing something wrong?
Executing:
bower install thoughtbot/bourbon#5.0.0-beta.7
displays:
Additional error details:
Available versions in https://github.com/thoughtbot/bourbon.git:4.2.7, 4.2.6, 4.2.5, 4.2.4, 4.2.3, 4.2.2, 4.2.1, 4.2.0, 4.1.1, 4.1.0, 4.0.2, 4.0.1, 4.0.0, 4.0.0-rc.2, 4.0.0-rc.1, 3.2.4, 3.2.3, 3.2.2, 3.2.1, 3.2.0, 3.2.0-beta.2, 3.2.0-beta.1, 3.1.8, 3.1.7, 3.1.6, 3.1.5, 3.1.4, 3.1.3, 3.1.2, 3.1.1, 3.1.0, 3.0.1, 3.0.0, 2.1.3, 2.1.2, 2.1.1, 2.1.0, 1.4.0, 1.3.6, 1.3.5, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.0, 1.1.0, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0.0, 0.2.1, 0.2.0, 0.1.9, 0.1.8, 0.1.7, 0.1.6, 0.1.5, 0.1.4, 0.1.3, 0.1.2, 0.1.1, 0.1.0, 0.0.9, 0.0.8, 0.0.7, 0.0.6, 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1
Bower will always default to installing the current stable version, which at the time of this writing is 4.2.7. To install a pre-release, like a beta, you’ll need to specify the version:
bower install bourbon#v5.0.0.beta.7
Reference: https://bower.io/docs/api/#install