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

Cannot access shared libraries #2

Closed
mike-engel opened this issue Jul 31, 2019 · 6 comments
Closed

Cannot access shared libraries #2

mike-engel opened this issue Jul 31, 2019 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@mike-engel
Copy link
Collaborator

mike-engel commented Jul 31, 2019

Note: This was transferred from the official now-builders repo.

I'm using a library that uses pq-sys, which tries to load libpq at runtime. Whenever the lambda is invoked, it encounters this error:

/var/task/bootstrap: error while loading shared libraries: libpq.so.5:
cannot open shared object file: No such file or directory

I'm not familiar with this stuff, but I managed to verify that:

  • libpq.so.5 is located in /usr/lib64
  • LD_LIBRARY_PATH includes /usr/lib64
  • PQ_LIB_DIR includes /usr/lib64

It seems the lambda is not able access shared libraries at runtime. Here's an example deployment for reference.

@mike-engel mike-engel added the bug Something isn't working label Jul 31, 2019
@mike-engel mike-engel self-assigned this Jul 31, 2019
@jacobmischka
Copy link
Contributor

jacobmischka commented Aug 1, 2019

Bummer about musl being more difficult than anticipated. I'm not super familiar with AWS lambdas, is accessing shared libraries possible or is static linking the only way forward?

It really doesn't matter to me how it happens, but it would be wonderful if I could get rust to talk to a Postgres (Edit: Actually, I'm using MySQL instead, though the same concept applies, ha) database in any way at all. Should I abandon diesel and look for a different solution, or is this issue something that can be fixed?

Thanks for your continued help with this!

@mike-engel
Copy link
Collaborator Author

One option I could see is to include shared libraries in the build as static files. You would have to change the environment variables/rust configuration to look in that place rather than in the normal locations, but that could be an alternative.

Admittedly I don't have a ton of systems knowledge here, so I don't know why diesel requires static links vs. dynamic ones (or maybe that was just the solution for now lambdas).

@jacobmischka
Copy link
Contributor

Yeah that was just the solution for the lambdas, dynamic links work just fine in other environments.

Thanks for the suggestion, I'm going to try that for a while. Bummer that the iteration loop is just so long, compiling for 5 minutes just to get the same error as before is starting to get soul crushing ha.

@mike-engel
Copy link
Collaborator Author

@jacobmischka I totally understand that! I've been there many times before. Hopefully #1 will help 😄

@jacobmischka
Copy link
Contributor

Hey, that was significantly easier than I thought, thanks so much for your direction.

I was able to get it to successfully use the libraries by including a lib directory containing the necessary .so files, and using the following now.json:

{
	"version": 2,
	"builds": [
		{
			"src": "Cargo.toml",
			"use": "now-rust",
			"config": {
				"includeFiles": [
					"lib/**",
				]
			}
		}
	],
	"env": {
		"LD_LIBRARY_PATH": "lib/"
	},
	"build": {
		"env": {
			"MYSQLCLIENT_LIB_DIR": "lib",
			"LD_LIBRARY_PATH": "lib/"
		}
	}
}

@mike-engel
Copy link
Collaborator Author

Wonderful! So glad it worked for you and that we have a nice alternative. I'll add it to the README soon. Thanks for testing!

ecklf added a commit that referenced this issue Mar 8, 2023
* dedup body

* merge pub use
ecklf added a commit that referenced this issue Mar 13, 2023
* initial rework

* add tsconfig

* add demo

* update Cargo.toml

* update README

* rename exports

* rename exported types, add prettier

* 4.0.1-canary.0

* use canary for demo, cleanup

* use style guide, cleanup

* update README

* add more examples

* improve examples

* polish demos

* demo: nextjs, fix layout, use identical seed

* runtime: used boxed err

* update dep, simplify examples

* merged handler example (wip)

* Change `impl IntoResponse` into `Response<Body>` (#1)

* Rework to allow merging api endpoints

* Rework all examples and simplify structure

* remove `IntoResponse`

---------

Co-authored-by: Florentin / 珞辰 <ecklf@icloud.com>

* dedup body (#2)

* dedup body

* merge pub use

* update docs, use Cargo workspaces

* update examples, `0.2.0`

* `4.0.0-canary.1`

* fix typo

* migrate fixtures tests (wip)

* migrate fixtures tests - 2 (wip)

* migrate fixtures tests - 3 (wip)

* add dynamic path example

* `4.0.0-canary.2`

* migrate fixtures test

* add husky

* add `.env.example` for cron

* add http helpers (#3)

* add http helpers

* remove opinionated payload

* re-add direct crate ref, fix invalid eslint

* `4.0.0-canary.3`

* `0.2.1`

* remove merged example

* update README

* cleanup workspace members

* cleanup

* fix newline

* rm gitignore from test

* `4.0.0.beta.0`

---------

Co-authored-by: Douglas Parsons <dglsparsons@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants