boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
678 stars 46 forks source link

New install. Unable to create a project #288

Closed az-z closed 1 year ago

az-z commented 1 year ago

Hello, the following seemed to be a new behavior since I last used (installed) TS ~6 months ago.

New install on Fedora 37 with aws cli and terraform ( latest, OS updated daily) Install is done using rpm from bolt's rpm repo.

as a user, new project:

(base) [az@fedora WWWPRIV-65-iac-vm]$ terraspace new project SoPro --plugin aws --examples --config --test 
=> Creating new project called SoPro
      create  SoPro
      create  SoPro/.gitignore
      create  SoPro/Gemfile
      create  SoPro/README.md
      create  SoPro/Terrafile
      create  SoPro/config/app.rb
=> Installing dependencies with: bundle install
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Using concurrent-ruby 1.1.10
Following files may not be writable, so sudo is needed:
  /opt/terraspace/embedded/bin
  /opt/terraspace/embedded/lib/ruby/gems/3.0.0
  /opt/terraspace/embedded/lib/ruby/gems/3.0.0/build_info
  /opt/terraspace/embedded/lib/ruby/gems/3.0.0/cache
  /opt/terraspace/embedded/lib/ruby/gems/3.0.0/doc
  /opt/terraspace/embedded/lib/ruby/gems/3.0.0/extensions
  /opt/terraspace/embedded/lib/ruby/gems/3.0.0/gems
  /opt/terraspace/embedded/lib/ruby/gems/3.0.0/plugins
  /opt/terraspace/embedded/lib/ruby/gems/3.0.0/specifications
Using aws-eventstream 1.2.0
Fetching minitest 5.17.0
Fetching aws-partitions 1.689.0

Your user account isn't allowed to install to the system RubyGems.
  You can cancel this installation and run:

      bundle config set --local path 'vendor/bundle'
      bundle install

  to install the gems into ./vendor/bundle/, or you can enter your password
  and install the bundled gems to RubyGems using sudo.

  Password: 

I'm not sure why there is a need to install anything into /opt. But, if that is a requirement for creating a new project level ( read "default" ) work item, then that should be specified as rpm dependency and probably installed during ts rpm install too.

Current state: blocked on the work, since rubygem requirements are not covered in the documentation and I'm not familiar with ruby.

tongueroo commented 1 year ago

🤔 This might be a clue

Following files may not be writable, so sudo is needed

This is probably/might be system specific, though and more of a question. Maybe at some point some other files were installed with different root level permissions in /opt/terrasace. maybe with some other command. Just a guess 👌 There seems to be something about permissions though.

I'm not sure why there is a need to install anything into /opt

The standalone installers use https://github.com/chef/omnibus to create the installer package. Omnibus installs things into the /opt folder and vendorizes everything including a ruby interpreter. So both the ruby interpreter and gems are installed into the /opt folder. The bundle install that is ran as part of terraspace new project is just installing gems and having some permissions issues.

FWIW, the aws cli similarly vendorizes the python interpreter but believe AWS uses their own custom packaging tool.

Mabe try to fix the permissions and then try again:

sudo chown `whoami`:`whoami` /opt/terraspace

After fixing the permissions with chown, you can also try cd into the folder and running bundler install directly.

cd SoPro
bundle install

However, if upgrading terraspace, actually recommend using bundler. Found it's more than about just updating terraspace but the other gems/libraries could require updating also. Here's the docs that cover this:

I'm not familiar with ruby.

Hope that the permissions fixes things above. If not, you might have to use gem installer. This may help if you end up having to go that route:

az-z commented 1 year ago

in addition: the rpm uninstall section needs updating since it does not remove installed wrappers properly:

Removed:
  terraspace-2.2.3-1.amazon2.x86_64                                                                                                                          

Complete!
[root@fedora ~]# 
[root@fedora ~]# 
[root@fedora ~]# gem install terraspace
/usr/local/bin/gem: line 5: /opt/terraspace/embedded/bin/gem: No such file or directory
[root@fedora ~]# gem install terraspace
/usr/local/bin/gem: line 5: /opt/terraspace/embedded/bin/gem: No such file or directory
[root@fedora ~]# gem
/usr/local/bin/gem: line 5: /opt/terraspace/embedded/bin/gem: No such file or directory
[root@fedora ~]# gem
/usr/local/bin/gem: line 5: /opt/terraspace/embedded/bin/gem: No such file or directory
[root@fedora ~]# which gem
/usr/local/bin/gem
[root@fedora ~]# ls -l /usr/local/bin/gem
-rwxr-xr-x 1 root root 132 Jan  9 12:53 /usr/local/bin/gem
[root@fedora ~]# file /usr/local/bin/gem
/usr/local/bin/gem: Bourne-Again shell script, ASCII text executable
[root@fedora ~]# more /usr/local/bin/gem
#!/bin/bash
unset GEM_HOME
unset GEM_PATH
export PATH=/opt/terraspace/embedded/bin:$PATH
exec /opt/terraspace/embedded/bin/gem "$@"
[root@fedora ~]# which ruby
/usr/local/bin/ruby
[root@fedora ~]# ls -l /usr/local/bin/ruby
-rwxr-xr-x 1 root root 133 Jan  9 12:53 /usr/local/bin/ruby
[root@fedora ~]# more /usr/local/bin/ruby
#!/bin/bash
unset GEM_HOME
unset GEM_PATH
export PATH=/opt/terraspace/embedded/bin:$PATH
exec /opt/terraspace/embedded/bin/ruby "$@"
tongueroo commented 1 year ago

Yes. This is noted in https://terraspace.cloud/docs/install/standalone/details/uninstall/

az-z commented 1 year ago

.. This is probably/might be system specific, though and more of a question. Maybe at some point some other files were installed with different root level permissions in /opt/terrasace. maybe with some other command. Just a guess ok_hand There seems to be something about permissions though.

This is interesting. on my other Fedora 35 the ts was installed ( on 2022 10 08) into /usr/local/bin . Worked perfectly fine. // over the weekend i upgraded the system to latest 37, so i can't say if it works now.

Either way, the root -> dnf (aka yum) install is the only way i 've been installing the software.

If I have to change the permissions on the /opt/terraspace - there should be a note in the doc, no ?

tongueroo commented 1 year ago

Yes. This is noted in https://terraspace.cloud/docs/install/standalone/details/permissions/

az-z commented 1 year ago

I wish I didn't upgrade F35. But on the upgraded system the permissions on /opt/terraspace is 754.

I uninstalled the rpm and installed gem with ruby-dev ( this is something you probably want to add to the doc), so that i can proceed with gem install. the subsequent "terraspace new project" failed again with multiple errors, such as:

Bundler::PermissionError: There was an error while trying to write to `/usr/share/gems/cache/aws-sdk-dynamodb-1.80.0.gem`. It is likely that you need to
grant write permissions for that path.

in addition, the /opt does not have terrspace subdir.

az-z commented 1 year ago

Please reopen the issue - if this fails on me, I'm sure a lot of folks will have the same problem.

az-z commented 1 year ago

on the upgraded system "terraspace new project tada" fails now too.

From the end-user perspective - this version is broken. :(