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

Can't find extern crate #348

Closed
duartebranco01 opened this issue Jun 7, 2024 · 3 comments · Fixed by #355
Closed

Can't find extern crate #348

duartebranco01 opened this issue Jun 7, 2024 · 3 comments · Fixed by #355
Assignees

Comments

@duartebranco01
Copy link

duartebranco01 commented Jun 7, 2024

Describe the bug

Hello, I'm having an error when the Rust code generated by the optimizer builder can't import extern crate:

 --> C:\Users\User\.cargo\registry\src\index.crates.io-6f17d22bba15001f\optimization_engine-0.9.0\src\constraints\affine_space.rs:3:1
  |
3 | extern crate modcholesky;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for ndarray
 --> C:\Users\User\.cargo\registry\src\index.crates.io-6f17d22bba15001f\optimization_engine-0.9.0\src\constraints\affine_space.rs:4:1
  |
4 | extern crate ndarray;
  | ^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0433]: failed to resolve: use of undeclared crate or module roots
  --> C:\Users\User\.cargo\registry\src\index.crates.io-6f17d22bba15001f\optimization_engine-0.9.0\src\constraints\epigraph_squared_norm.rs:53:32
   |
53 |         let cubic_poly_roots = roots::find_roots_cubic(a3, a2, a1, a0);
   |                                ^^^^^ use of undeclared crate or module roots

These crates exist in the index.crates.io-6f17d22bba15001f folder.

Do I need to configure some kind of path variable or use specific versions of something?

To Reproduce

Steps to reproduce the behavior:

Run the builder (with the versions of programs indicated bellow):

builder = og.builder.OpEnOptimizerBuilder(problem, meta, build_cfg, solver_cfg)
builder.build()

Expected behavior

No problem importing extern crate.

System information:

⚠️ Please, provide the following information:

  • System/Platform: PC
  • OS: Windows 10
  • rustup version: 1.27.1
  • rustc version: 1.78.0
  • cargo version: 1.78.0
  • Python version: 3.9.13

Additional context

Builder params:

problem = og.builder.Problem(u, p, sum_squared_error) \
    .with_penalty_constraints(penalty_constraints) \
    .with_constraints(u_bounds)

build_cfg = og.config.BuildConfiguration() \
    .with_build_directory("build") \
    .with_tcp_interface_config() \
    .with_build_c_bindings()

meta = og.config.OptimizerMeta() \
    .with_optimizer_name("my_optimizer")

solver_cfg=og.config.SolverConfiguration()\
    .with_tolerance(1e-5)\
    .with_delta_tolerance(1e-4)\
    .with_initial_penalty(1e3)

builder = og.builder.OpEnOptimizerBuilder(problem, meta, build_cfg, solver_cfg)

builder.build()
@alphaville alphaville self-assigned this Jun 9, 2024
@alphaville
Copy link
Owner

I've never encountered something like this on Linux or MacOS. The code also works on Google Colab.

@ruairimoran have you seen anything similar on Windows?

@duartebranco01 a possible explanation can be that you're trying to run the code on a machine without an Internet connection, so cargo fails to download the dependencies.

@alphaville
Copy link
Owner

It seems that this error is only likely to happen if the machine on which you're compiling is not connected to the Internet. When we need to use OpEn on a robot or vehicle, I would first compile on my laptop, test the code in simulations, then move it to the robot and compile there with cargo build.

Let me know if this resolves the issue.

@alphaville
Copy link
Owner

Fixed in #355

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

Successfully merging a pull request may close this issue.

2 participants