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

Ubuntu 18.04 cannot build (multiple imports and types errors) #73

Closed
Mec-iS opened this issue Sep 20, 2018 · 4 comments
Closed

Ubuntu 18.04 cannot build (multiple imports and types errors) #73

Mec-iS opened this issue Sep 20, 2018 · 4 comments

Comments

@Mec-iS
Copy link

Mec-iS commented Sep 20, 2018

Hi,

I am trying to build different libraries (mostly Rust-based Web servers) depending from this library in Ubuntu and I get consistently this error multiple times, with different libraries and different Rust versions (stable 1.29 and nightly 1.30.0) when running cargo build with a toml that specifies deps that requires pkg-config:

error: expected expression, found `]`                                                
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:70:60
   |                                                                                 
70 |             if options.statik && !is_system_lib(val, &dirs[]) {                 
   |                                                            ^ expected expression
                                                                                     
error[E0433]: failed to resolve. Could not find `old_io` in `std`                    
 --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:4:10
  |                                                                                  
4 | use std::old_io::fs::PathExtensions;                                             
  |          ^^^^^^ Could not find `old_io` in `std`                                 
                                                                                     
error[E0432]: unresolved import `std::old_io`                                        
 --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:3:10
  |                                                                                  
3 | use std::old_io::Command;                                                        
  |          ^^^^^^ Could not find `old_io` in `std`                                 
                                                                                     
error[E0433]: failed to resolve. Use of undeclared type or module `Path`             
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:65:23
   |                                                                                 
65 |             dirs.push(Path::new(val));                                          
   |                       ^^^^ Use of undeclared type or module `Path`              
                                                                                     
error[E0433]: failed to resolve. Use of undeclared type or module `Path`             
   --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:103:16
    |                                                                                
103 |     let root = Path::new("/usr");                                              
    |                ^^^^ Use of undeclared type or module `Path`                    
                                                                                     
error[E0425]: cannot find function `getenv` in module `os`                           
 --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:9:9
  |                                                                                  
9 |     os::getenv("HOST") == os::getenv("TARGET") ||                                
  |         ^^^^^^ not found in `os`                                                 
                                                                                     
error[E0425]: cannot find function `getenv` in module `os`                           
 --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:9:31
  |                                                                                  
9 |     os::getenv("HOST") == os::getenv("TARGET") ||                                
  |                               ^^^^^^ not found in `os`                           
                                                                                     
error[E0425]: cannot find function `getenv` in module `os`                           
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:10:13
   |                                                                                 
10 |         os::getenv("PKG_CONFIG_ALLOW_CROSS") == Some("1".to_string())           
   |             ^^^^^^ not found in `os`                                            
                                                                                     
error[E0425]: cannot find function `getenv` in module `os`                           
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:23:12
   |                                                                                 
23 |     if os::getenv(format!("{}_NO_PKG_CONFIG", envify(name)).as_slice()).is_some() {
   |            ^^^^^^ not found in `os`                                             
                                                                                     
error[E0425]: cannot find function `getenv` in module `os`                           
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:82:25
   |                                                                                 
82 |     let statik = if os::getenv(format!("{}_STATIC", name).as_slice()).is_some() {
   |                         ^^^^^^ not found in `os`                                
                                                                                     
error[E0425]: cannot find function `getenv` in module `os`                           
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:84:19
   |                                                                                 
84 |     } else if os::getenv(format!("{}_DYNAMIC", name).as_slice()).is_some() {    
   |                   ^^^^^^ not found in `os`                                      
                                                                                     
error[E0425]: cannot find function `getenv` in module `os`                           
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:86:19
   |                                                                                 
86 |     } else if os::getenv("PKG_CONFIG_ALL_STATIC").is_some() {                   
   |                   ^^^^^^ not found in `os`                                      
                                                                                     
error[E0425]: cannot find function `getenv` in module `os`                           
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:88:19
   |                                                                                 
88 |     } else if os::getenv("PKG_CONFIG_ALL_DYNAMIC").is_some() {                  
   |                   ^^^^^^ not found in `os`                                      
                                                                                     
error[E0412]: cannot find type `Path` in this scope                                  
   --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:101:38
    |                                                                                
101 | fn is_system_lib(name: &str, dirs: &[Path]) -> bool {                          
    |                                      ^^^^ not found in this scope              
help: possible candidate is found in another module, you can import it into scope    
    |                                                                                
3   | use std::path::Path;                                                           
    |                                                                                
                                                                                     
error[E0599]: no method named `as_slice` found for type `std::string::String` in the current scope
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:23:61
   |                                                                                 
23 |     if os::getenv(format!("{}_NO_PKG_CONFIG", envify(name)).as_slice()).is_some() {
   |                                                             ^^^^^^^^            
                                                                                     
error[E0599]: no method named `as_slice` found for type `std::string::String` in the current scope
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:82:59
   |                                                                                 
82 |     let statik = if os::getenv(format!("{}_STATIC", name).as_slice()).is_some() {
   |                                                           ^^^^^^^^              
                                                                                     
error[E0599]: no method named `as_slice` found for type `std::string::String` in the current scope
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:84:54
   |                                                                                 
84 |     } else if os::getenv(format!("{}_DYNAMIC", name).as_slice()).is_some() {    
   |                                                      ^^^^^^^^                   
                                                                                     
   Compiling linked-hash-map v0.4.2                                                  
error[E0369]: binary operation `==` cannot be applied to type `std::char::ToUppercase`
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:97:55
   |                                                                                 
97 |     name.chars().map(|c| c.to_uppercase()).map(|c| if c == '-' {'_'} else {c})  
   |                                                       ^^^^^^^^                  
   |                                                                                 
   = note: an implementation of `std::cmp::PartialEq` might be missing for `std::char::ToUppercase`
                                                                                     
error[E0308]: if and else have incompatible types                                    
  --> /home/lorenzo/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.1.7/src/lib.rs:97:52
   |                                                                                 
97 |     name.chars().map(|c| c.to_uppercase()).map(|c| if c == '-' {'_'} else {c})  
   |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected char, found struct `std::char::ToUppercase`
   |                                                                                 
   = note: expected type `char`                                                      
              found type `std::char::ToUppercase`                                    
                                                                                     
error: aborting due to 19 previous errors                                            
                                                                                     
Some errors occurred: E0308, E0369, E0412, E0425, E0432, E0433, E0599.               
For more information about an error, try `rustc --explain E0308`.                    
error: Could not compile `pkg-config`.                

I did a brief investigation on the dependency tree and found out that:

pkg-config
├── pkg-config v0.3.14
    │       └── pkg-config v0.1.7

the newest version depends from the old one (0.1.7), that breaks the build.
This is the Dockerfile I am using to build the containers:

RUN apt-get install -y wget build-essential software-properties-common curl pkg-config \
                       libssh-dev cmake

ENV RUSTUP_HOME=/usr/local/rustup \
    CARGO_HOME=/usr/local/cargo \
    PATH=/usr/local/cargo/bin:$PATH

RUN set -eux; \
    \
    url="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"; \
    wget "$url"; \
    chmod +x rustup-init; \
    ./rustup-init -y --no-modify-path --default-toolchain stable; \   # or nightly is the same
    rm rustup-init; \
    chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
    rustup --version; \
    cargo --version; \
    rustc --version;

CMD ["cargo", "build"]

NOTE: i get the same error on my local machine outside the container.

@Mec-iS Mec-iS changed the title Ubuntu 18.04 cannot build Ubuntu 18.04 cannot build (multiple imports and types errors) Sep 20, 2018
@sdroege
Copy link
Collaborator

sdroege commented Sep 20, 2018

Thanks for the bug report. pkg-config-rs does not depend on an older version of itself, but version 0.1.7 is indeed ancient.

How can this be reproduced, what exactly are you building and how?

@Mec-iS
Copy link
Author

Mec-iS commented Sep 20, 2018

Using these dependencies always breaks the build for me, with the systems and versions specified above:

[dependencies]
actix = "0.7"
actix-web = "0.7"
futures = "0.1"
env_logger = "0.5"
bytes = "0.4"
postgres = "0.4.2"

And also (this one can run only on nightly):

[dependencies]
rocket = "0.3.16"
rocket_codegen = "0.3.16"
diesel = { version = "1.0.0", features = ["postgres"] }
dotenv = "0.9.0"

@sdroege
Copy link
Collaborator

sdroege commented Sep 20, 2018

Your problem is that you depend on postgres 0.4 (which is ancient), which depends on openssl 0.2, which depends on openssl-sys 0.2, which in turn depends on the ancient pkg-config 0.1.7.

If you switch to postgres 0.15 it's all fine. And also nothing will actually depend on pkg-config anymore.


I can't reproduce it with the second of dependencies, nothing there depends on pkg-config.

@sdroege sdroege closed this as completed Sep 20, 2018
@Mec-iS
Copy link
Author

Mec-iS commented Sep 20, 2018

Thanks. Much appreciated.

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