Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand_path': couldn't find login name -- expanding ~' (ArgumentError) #142

Closed
edipoReboucas opened this issue Jan 15, 2020 · 1 comment
Closed
Assignees
Labels

Comments

@edipoReboucas
Copy link

edipoReboucas commented Jan 15, 2020

I'm trying use Support authorization options on request

When I run with a user without $HOME directory, in the case www-data (apache user), I'm getting the error:

/var/lib/gems/2.5.0/gems/twurl-0.9.5/lib/twurl/rcfile.rb:6:in `expand_path': couldn't find login name -- expanding `~' (ArgumentError)
	from /var/lib/gems/2.5.0/gems/twurl-0.9.5/lib/twurl/rcfile.rb:6:in `directory'
	from /var/lib/gems/2.5.0/gems/twurl-0.9.5/lib/twurl/rcfile.rb:14:in `file_path'
	from /var/lib/gems/2.5.0/gems/twurl-0.9.5/lib/twurl/rcfile.rb:18:in `load'
	from /var/lib/gems/2.5.0/gems/twurl-0.9.5/lib/twurl/rcfile.rb:30:in `initialize'
	from /var/lib/gems/2.5.0/gems/twurl-0.9.5/lib/twurl/oauth_client.rb:6:in `new'
	from /var/lib/gems/2.5.0/gems/twurl-0.9.5/lib/twurl/oauth_client.rb:6:in `rcfile'
	from /var/lib/gems/2.5.0/gems/twurl-0.9.5/lib/twurl/oauth_client.rb:12:in `load_from_options'
	from /var/lib/gems/2.5.0/gems/twurl-0.9.5/lib/twurl/cli.rb:25:in `dispatch'
	from /var/lib/gems/2.5.0/gems/twurl-0.9.5/lib/twurl/cli.rb:21:in `run'
	from /var/lib/gems/2.5.0/gems/twurl-0.9.5/bin/twurl:4:in `<top (required)>'
	from /usr/local/bin/twurl:23:in `load'
	from /usr/local/bin/twurl:23:in `<main>'

I belive that is correlated this bug in another ruby project.

# fixes: couldn't find login name expanding tilde (cont.)

As workaround, I change RCFile class

module Twurl
  class RCFile
    FILE = '.twurlrc'
    class << self
      def directory
        @@directory ||= '' 
        #@@directory ||= File.expand_path('~')

Expected behavior

Send request without .twurlrc file

Actual behavior

twurl crash and print a error message

Steps to reproduce the behavior

  • install a php + apache setup on linux
  • install twurl
  • create php script with a shell_exec command executing twurl with all authentication options
@smaeda-ks
Copy link
Collaborator

@edipoReboucas Thanks. For me, the proper fix is to rewrite this logic:
https://github.com/twitter/twurl/blob/master/lib/twurl/oauth_client.rb#L12-L26

there are too many if conditions and it should be simplified. I'll look into this and open a PR later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants