question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using su_user with use_su_login yields an error with a macOS target

See original GitHub issue

Describe the bug Using su_user with use_su_login yields an error with a macOS target. Using use_su_login alone works without specifying the user, but it does not seem to load and shell profiles (nor .zshrc or .bash_profile):

-> Proposed changes:
    Groups: mac_vms
    [vm]   Operations: 1   Commands: 1

--> Beginning operation run...
--> Starting operation: Test ruby ("commands=['which ruby']",)
    [pyinfra\api\operations] Starting operation Test ruby on vm
    [pyinfra\api\connectors\ssh] Running command on vm: (pty=None) su -l the_user -s `which sh` -c 'which ruby'
[vm] >>> su -l the_user -s `which sh` -c 'which ruby'
[vm] su: Sorry
    [pyinfra\api\connectors\ssh] Waiting for exit status...
    [pyinfra\api\connectors\ssh] Command exit status: 1
    [vm] Error
    [pyinfra\api\state] Failing hosts: vm
No hosts remaining!
--> ←[31m←[1mpyinfra error←[0m:

To bring some context: I have a target macOS machine with chruby set up using a specific version of ruby, under .rubies built with ruby-install. I want to install some gems on the target machine with pyinfra, but this requires it to have chruby run beforehand so that it selects the correct gem version, instead of the one pre-installed with macOS. The commands to do this are in the .zshrc, and when I login to an SSH shell it works as intended. However, even when running with use_su_login = True, it returns the incorrect version of ruby:

server.shell(
    name = 'Test ruby'
    ,use_su_login = True
    ,commands = [ 'which ruby' ]
)

# Results in:
[vm] >>> sh -c 'which ruby'
[vm] /usr/bin/ruby

From an SSH login shell:

> which ruby
/Users/USER/.rubies/ruby-2.7.1/bin/ruby

To Reproduce With a macOS target (my target is Catalina 10.15.6) such an operation with both su_user and use_su_login specified:

server.shell(
    name = 'Test ruby'
    ,su_user      = host.data.user
    ,use_su_login = True
    ,commands     = [ 'which ruby' ]
)

Expected behavior No errors to occur

Meta

  • Include output of pyinfra --support. Note that I am on 1.0.2 as I ran into some other issues with since 1.0.3. I plan to report the issues as well as soon as I resolve this so I can continue with the other ops.
System: Windows
      Platform: Windows-10-10.0.19041-SP0
      Release: 10
      Machine: AMD64
    pyinfra: v1.0.2
    Executable: C:\Users\the_user\AppData\Local\Programs\Python\Python38-32\Scripts\pyinfra.exe
    Python: 3.8.3 (CPython, MSC v.1925 32 bit (Intel))
  • How was pyinfra installed (source/pip)? pip

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
Fizzadarcommented, Sep 2, 2020

Thanks for testing @harold-b - I’ve added https://github.com/Fizzadar/pyinfra/issues/426 to track the login shell issue 😬

1reaction
harold-bcommented, Aug 28, 2020

Excellent! Thanks for your hard work. I will have a try with the new version as soon as I can and report back for confirmation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

If an error occurred while updating or installing macOS
The message might say that an error occurred while downloading, preparing, or installing, or that the installer is damaged or could not be ......
Read more >
NET MAUI macOS target publishing/archiving #5399 - GitHub
Description. I have been trying to see if publishing a macOS (Mac Catalyst) app through .NET MAUI works at the moment. Unsigned App...
Read more >
Xcode 9 macos deployment target (with c++) giving error
When I try building a make project (from a c++ repository) I get the following error in XCode 9 : ...
Read more >
Troubleshoot Mac OS 10.x system errors, freezes
Comprehensive troubleshooting document for system software-related errors and crashes that occur when you use Adobe products on Mac OS 10.x.
Read more >
Qt for macOS | Qt 6.4
Instead, macOS uses its own native windowing system that is accessible ... on a macOS version below the deployment target macOS or Qt...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found