# Issue importing a library

**URL:** <https://forum.fuel.network/t/issue-importing-a-library/2868>\
**Category:** Sway\
**Created:** [July 11, 2023, 2:21pm UTC](https://forum.fuel.network/t/issue-importing-a-library/2868 "2023-07-11T14:21:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![timotejGerzelj](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/timotejgerzelj/32/1553_2.png) [@timotejGerzelj](https://forum.fuel.network/u/timotejGerzelj)\
**Post date:** [July 11, 2023, 2:21pm UTC](https://forum.fuel.network/t/issue-importing-a-library/2868/1 "2023-07-11T14:21:47Z")

</div>

I created a new internal library by following the sway docs, but I have the issue whenever I try to import it to main.sw and `forc build` I receive this error  
`mod internal_lib; | ^^^ Expected an item. 4 | 5 | use internal_lib::Organisation;`

This is the library I created:

```auto

library;

use std::storage::storage_vec::*;

pub struct Organisation {
    owner: str[40],
    sellers: StorageVec<str[40]>,
}

impl Organisation {
    pub fn new(owner: str) -> Self {
        Self {
            owner,
            
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![sandusky](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/sandusky/32/1313_2.png) [@sandusky](https://forum.fuel.network/u/sandusky)\
**Post date:** [July 11, 2023, 2:26pm UTC](https://forum.fuel.network/t/issue-importing-a-library/2868/2 "2023-07-11T14:26:29Z")

</div>

Hi there!  
Can you add the code where you are importing the lib and the version of the compiler you are working with?  
`fuelup show`

---

<div class="post-metadata">

**Author:** ![timotejGerzelj](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/timotejgerzelj/32/1553_2.png) [@timotejGerzelj](https://forum.fuel.network/u/timotejGerzelj)\
**Post date:** [July 11, 2023, 2:39pm UTC](https://forum.fuel.network/t/issue-importing-a-library/2868/3 "2023-07-11T14:39:38Z")

</div>

Hi, thanks for the quick response!  
the import:  
`mod internal\_lib;

use internal\_lib::Organisation;`

the version:

`Default host: x86\_64-unknown-linux-gnu  
fuelup home: /home/timotej/.fuelup

## installed toolchains

beta-2-x86\_64-unknown-linux-gnu  
beta-3-x86\_64-unknown-linux-gnu  
latest-x86\_64-unknown-linux-gnu  
test\_toolchain (default)

## active toolchain

test\_toolchain (default)  
forc : 0.35.3  
- forc-client  
- forc-deploy : 0.35.3  
- forc-run : 0.35.3  
- forc-doc : 0.35.3  
- forc-explore - not found  
- forc-fmt : 0.35.3  
- forc-index - not found  
- forc-lsp : 0.35.3  
- forc-tx : 0.35.3  
- forc-wallet : 0.2.2  
fuel-core - not found  
fuel-indexer - not found

## fuels versions

forc : 0.36`

---

<div class="post-metadata">

**Author:** ![calldelegation](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/calldelegation/32/1484_2.png) [@calldelegation](https://forum.fuel.network/u/calldelegation)\
**Post date:** [July 12, 2023, 3:29am UTC](https://forum.fuel.network/t/issue-importing-a-library/2868/4 "2023-07-12T03:29:30Z")

</div>

Hey @timotejGerzelj thanks for the question! Can you please try the following? I was able to build your files fine after these steps. Note I had to resolve a few issues with your internal\_lib.sw file.

1. `$ fuelup self update` which grabs the latest version of fuelup
2. `$ fuelup default latest` which sets the tool chain to the one you just got

This is the toolchain im running

```auto
➜ lib-import fuelup show
Default host: aarch64-apple-darwin
fuelup home: /Users/calldelegation/.fuelup

installed toolchains
--------------------
beta-3-aarch64-apple-darwin
latest-aarch64-apple-darwin (default)
latest-2023-02-18-aarch64-apple-darwin
latest-2023-04-12-aarch64-apple-darwin

active toolchain
-----------------
latest-aarch64-apple-darwin (default)
  forc : 0.42.0
    - forc-client
      - forc-deploy : 0.42.0
      - forc-run : 0.42.0
    - forc-doc : 0.42.0
    - forc-explore : 0.28.1
    - forc-fmt : 0.42.0
    - forc-index : 0.17.3
    - forc-lsp : 0.42.0
    - forc-tx : 0.42.0
    - forc-wallet : 0.2.3
  fuel-core : 0.18.3
  fuel-indexer : 0.17.3

fuels versions
---------------
forc : 0.43
forc-wallet : 0.43.0

```

Project structure

```auto
.
└── src/
    ├── internal_lib.sw
    └── main.sw

```

main.sw

```auto
contract;

mod internal_lib;

use ::internal_lib::Organisation;

abi MyContract {
    fn test_function() -> bool;
}

impl MyContract for Contract {
    fn test_function() -> bool {
        true
    }
}

```

internal\_lib.sw

```auto
library;

use std::storage::storage_vec::*;

pub struct Organisation {
    owner: str[40],
    sellers: StorageVec<str[40]>,
}

impl Organisation {
    pub fn new(owner: str[40], sellers: StorageVec<str[40]>) -> Self {
        Self {
            owner,
            sellers
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![timotejGerzelj](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/timotejgerzelj/32/1553_2.png) [@timotejGerzelj](https://forum.fuel.network/u/timotejGerzelj)\
**Post date:** [July 12, 2023, 10:51am UTC](https://forum.fuel.network/t/issue-importing-a-library/2868/5 "2023-07-12T10:51:45Z")

</div>

Hey @calldelegation thanks alot, this worked!

---

<div class="post-metadata">

**Author:** ![fsy412](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/fsy412/32/1561_2.png) [@fsy412](https://forum.fuel.network/u/fsy412)\
**Post date:** [July 13, 2023, 2:50pm UTC](https://forum.fuel.network/t/issue-importing-a-library/2868/6 "2023-07-13T14:50:45Z")

</div>

maybe it’s pub fn new(owner: str[40]) → Self {

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [August 3, 2023, 10:51am UTC](https://forum.fuel.network/t/issue-importing-a-library/2868/7 "2023-08-03T10:51:37Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
