linniksa / redmine_git_mirror

Adds ability to clone and fetch remote git repositories to redmine
MIT License
35 stars 20 forks source link

Dir.home causes ArgumentError (couldn't find login name -- expanding `~') #20

Open BrunoNagano opened 4 years ago

BrunoNagano commented 4 years ago

Hi,

I have been testing this plugin and it is great. However, I encountered the following error:

ArgumentError (couldn't find login name -- expanding `~')

I am not a ruby/rails developer, but I did some debugging. The error is being caused by the line Dir.home + "/.ssh/known_hosts" on the lib/redmine_git_mirror/ssh.rb file. The error is caused by the lack of a HOME variable being set on the httpd user installed by the Arch Linux package. I am not sure if this would occur on other distros, but I added the following to the file in order to get the home directory directly from the etc/passwd file.

require 'etc'
Etc.getpwuid.dir + "/.ssh/known_hosts"

Adding this issue as I am not really sure if this is the best fix for the problem and it might help someone who cannot get the plugin to work.

Thanks a lot for the plugin.