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

Silly question, but I just can't get this working from get go. #47

Open
brianr-dk opened this issue Jan 7, 2025 · 11 comments
Open

Silly question, but I just can't get this working from get go. #47

brianr-dk opened this issue Jan 7, 2025 · 11 comments

Comments

@brianr-dk
Copy link

Pardon my obvious ignorance here - this is my first attempt with Ruby/Gems.

If I get this "zipfile/gem", then what is the procedure to install it on the offline inside of a workplace, where there is NO connection outside.

I'm on a Window server and Ruby 3.3.6 "with devkit" is successfully installed.

I downloaded via the "https://github.com/larskanis/pg-ldap-sync/archive/refs/heads/master.zip" and when copied/unzipped on the windows server, it looks as if it contains the same files as on "https://github.com/larskanis/pg-ldap-sync"

Every gem install/check/dependency/info whatnot (--local --path) pg-ldap-sync I've tried fails miserably.

I just know there's something banal I have missed, being a n00b here :)

@larskanis
Copy link
Owner

You need several gems, which are downloaded as dependecies when you run gem install pg-ldap-sync at an online computer. You can take the files from c:\Ruby33-x64\lib\ruby\gems\3.3.0\cache\*.gem after install and copy it to the offline system. Then the files can be installed offline by running gem install pg-ldap-sync-0.5.0.gem from the directory the gems are stored.

You could also manually fetch all dependencies by following all runtime dependencies of https://rubygems.org/gems/pg-ldap-sync recursively and press "download" at all of them. For the pg gem you need the x64-mingw-ucrt platform version.

If all the gems are installed the command should be executed as described:

pg_ldap_sync -c my_config.yaml -vv

@brianr-dk
Copy link
Author

brianr-dk commented Jan 8, 2025 via email

@brianr-dk
Copy link
Author

I have a small additional question.

I managed to get the gem installed, and create my config file - but the test with pg_ldap_sync -c my_config.yaml -vv -t actually failed.

I am waiting for the details to get out from my environment to internet, but the main reason seems to be that ruby/gem expects files to be with Linux directory syntax "/" and fails with "specified module could not be found" (C:/RubyPath/To/pg_ext.so)

But Windows have no problems finding that pg_ext.so if I do a "DIR C:\RubyPath\To\pg_ext.so" (Created today when I installed it with:

subst X: "c:\postgresinstalldir\16" 
gem install pg-ldap-sync-0-5-0.gem  -- --with-pg-dir=X:
subst X: /D 

(The subst was apparently needed because without, gem install failed with some postgres err that it couldn't find pg_config)

Is there a step in "installing Ruby on Windows" that I might have skipped somehow?

@brianr-dk
Copy link
Author

Here's the details from failing to run the "pg_ldap_sync -c my_config.yaml -vv -t" on my Windows server that was installed, using the gem(s) from an online server's ruby 3.3.6 installation (I'm suspecting that the gem used was actually created on a Linux server):

TESTS:

cd C:\Ruby\all_pg-ldap-sync_gems_from_cache
pg_ldap_sync -c pg_ldap_sync.yaml -vv -t
<internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require': 126: The specified module could not be found.   - C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/pg-1.5.9/lib/pg_ext.so (LoadError)
        from <internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/pg-1.5.9/lib/pg.rb:49:in `block in <module:PG>'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/pg-1.5.9/lib/pg.rb:37:in `block in <module:PG>'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/pg-1.5.9/lib/pg.rb:42:in `<module:PG>'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/pg-1.5.9/lib/pg.rb:6:in `<top (required)>'
        from <internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from <internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/pg-ldap-sync-0.5.0/lib/pg_ldap_sync/application.rb:7:in `<top (required)>'
        from <internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from <internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/pg-ldap-sync-0.5.0/lib/pg_ldap_sync.rb:1:in `<top (required)>'
        from <internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from <internal:C:/Ruby33-x64/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/pg-ldap-sync-0.5.0/exe/pg_ldap_sync:3:in `<top (required)>'
        from C:/Ruby33-x64/bin/pg_ldap_sync:32:in `load'
        from C:/Ruby33-x64/bin/pg_ldap_sync:32:in `<main>'

Notice the wrong "/", changing them to "", and the files magically appears ? :)

cd C:\Ruby\all_pg-ldap-sync_gems_from_cache>
dir C:\Ruby33-x64\lib\ruby\gems\3.3.0\gems\pg-1.5.9\lib\pg_ext.so
	Directory of C:\Ruby33-x64\lib\ruby\gems\3.3.0\gems\pg-1.5.9\lib
	08-01-2025  10:06           203.264 pg_ext.so
	               1 File(s)        203.264 bytes

Does this also have a simple fix in the world of linux/windows incompatibilities ?

@larskanis
Copy link
Owner

You need the latest pg gem version for platform mingw-x64-ucrt and a ruby < 3.4. This is the compiled pg version. It sounds like you took the source gem, which you should uninstall.

@brianr-dk
Copy link
Author

Ruby is a steep and weird-ish learning curve for this dude :)
Thanks for quick responses!

Oh - could any of the stunts I do in Ruby/gems installation, in any way affect the currently installed postgresql windows database and it's adiitional configurations?
(Asking because I googled some suggestions that one has to install things looking as if a postgres installation is attempted 'in ruby' order to fix pg gem-issues)

@brianr-dk
Copy link
Author

Oh, sorry. I see now - the link to rubygems lists requirements. Thanks!
I'll try the mingw-x64-ucrt in stead .
/Brian

@brianr-dk
Copy link
Author

Ay-ay-ay!

Is there a special trick to persuade a Linux machine to fetch the windows version of a gem (the pg x64-mingw-ucrt)?
Or do we need to spin up a windows with Ruby to do that.

@larskanis
Copy link
Owner

Go to https://rubygems.org/gems/pg select 'all versions' then the needed version, then 'download' in the right panel.

@brianr-dk
Copy link
Author

Oh - snap ;)

As we say here in Denmark: "The first thing you go blind on, is the eye"!
Thanks again!
I hope this is the final "how to to basic stuff" from me ;)

@brianr-dk
Copy link
Author

It installed - that's so great!

However the gem install succeeds, yet complains about not being able to reach rubygems.org for some 'specs.4.8' - I guess that is slightly irrelevant and something internally related to ruby/gem/install itself.

Oh, and I stumbled over a slight issue with my understanding of yaml syntax - you can forget about "tab" ;)

I would consider this ruby-first-timer-course as completed - thanks for assisting, Lars! :D

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

No branches or pull requests

2 participants