# Dependency without dependency

**URL:** <https://discourse.julialang.org/t/dependency-without-dependency/73432>\
**Category:** General Usage\
**Tags:** package, development\
**Created:** [December 21, 2021, 12:32pm UTC](https://discourse.julialang.org/t/dependency-without-dependency/73432 "2021-12-21T12:32:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![davibarreira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davibarreira/32/20270_2.png) [@davibarreira](https://discourse.julialang.org/u/davibarreira)\
**Post date:** [December 21, 2021, 12:32pm UTC](https://discourse.julialang.org/t/dependency-without-dependency/73432/1 "2021-12-21T12:32:58Z")

</div>

Hey everyone, I have the following situation in my hands, and I’d like to get some perspective from the community:

Suppose I’m developing a package and I wish to provide the user with a function that requires a package like Flux.jl. Now, my package per se does not uses Flux, and I just wish to provide this function to the user such that he can use it “if” he has Flux.jl, for example:

```julia
using MyPackage
runfluxfunction()
# This returns an error.

```

```julia
using MyPackage
using Flux
runfluxfunction()
# This works.

```

I was wondering if it’s possible to do something like this, or if it’s bad practice for some reason. This would be really nice, cause this function might not be needed for every user, and I could leave Flux.jl out of as a dependency, which would make the precompilation faster.

---

<div class="post-metadata">

**Author:** ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)\
**Post date:** [December 21, 2021, 12:55pm UTC](https://discourse.julialang.org/t/dependency-without-dependency/73432/2 "2021-12-21T12:55:13Z")

</div>

See this package  
[https://github.com/JuliaPackaging/Requires.jl](https://github.com/JuliaPackaging/Requires.jl)  
it might solve your problem.

Tomas

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [December 21, 2021, 1:39pm UTC](https://discourse.julialang.org/t/dependency-without-dependency/73432/3 "2021-12-21T13:39:19Z")

</div>

You’ll also want to know about [https://github.com/JuliaLang/Pkg.jl/issues/1285](https://github.com/JuliaLang/Pkg.jl/issues/1285)

Won’t happen tomorrow though, just trying to drum up support.

---

<div class="post-metadata">

**Author:** ![davibarreira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davibarreira/32/20270_2.png) [@davibarreira](https://discourse.julialang.org/u/davibarreira)\
**Post date:** [December 21, 2021, 4:30pm UTC](https://discourse.julialang.org/t/dependency-without-dependency/73432/4 "2021-12-21T16:30:49Z")

</div>

Good to know there are option out there. I thought about using metaprogramming to do this. I mean, the function would be pretty much just a string that the end user could ‘eval’. But I guessed this was a “dont” for some reason. (I didn’t think it through too much).

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [December 21, 2021, 6:03pm UTC](https://discourse.julialang.org/t/dependency-without-dependency/73432/5 "2021-12-21T18:03:31Z")

</div>

I would go with Requires.jl. it’s quite straightforward.
