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

compile error, class.java.io is not available #1

Open
mununki opened this issue Jun 14, 2021 · 5 comments
Open

compile error, class.java.io is not available #1

mununki opened this issue Jun 14, 2021 · 5 comments

Comments

@mununki
Copy link

mununki commented Jun 14, 2021

Hi, thank you for your fantastic work.

I'm very new to clj and cljs. It might be a simple issue, but I can't figure out how to fix. I'd like to try to use shadow-env in my cljs project but I faced the compile error with this message.

The required namespace "clojure.java.io" is not available, it was required by "book_report/env.cljs".
"clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ?
;; env.cljs
(ns book-report.env
  (:refer-clojure :exclude [get])
  (:require [shadow-env.core :as env]
            [aero.core :as aero]
            [clojure.java.io :as io]))

#?(:clj
   (defn read-env [build-state]
     (let [aero-config                   {:stage (or (System/getenv "BR_ENV") :local)}
           [common
            server
            secret
            client] (->> ["common.edn"
                          "sever.edn"
                          "secret.edn"
                          "client.edn"]
                         (map #(some-> (io/resource %)
                                       (aero/read-config aero-config))))]
       {:common common
        :clj    (merge server secret)
        :cljs   client})))

(env/link get `read-env)

I guess clojure.jav a.io is not supposed to be compiled to javascript. So, the error message is reasonable in a way. But, it should be resolved because this library is supposed to be used in the cljs project. I think I missed something. Can you give me a tip to fix this?

@mtmr0x
Copy link

mtmr0x commented Jul 27, 2022

Same issue here. Do you got somewhere with the problem or is this still a problem @mattdamon108?

@mhuebert
Copy link
Owner

Hello, sorry I missed this the first time around.

It looks like you're trying to use Clojure (jvm) code inside a .cljs file, but that's only possible in a .clj file or in a .cljc file wrapped inside a reader conditional like #?(:clj ...clojure/java-code-here).

@mtmr0x
Copy link

mtmr0x commented Jul 27, 2022

Hi @mhuebert thanks for your response.

I'm actually trying to do it inside a .cljc file with the wrapper conditional, as you may see in this print

(just ignore the last line)

Screenshot 2022-07-27 at 14 48 13

Also, here's the log:

[shadow:watch ] The required namespace "clojure.java.io" is not available, it was required by "webapp/environment.cljc".
[shadow:watch ] "clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ?

@mhuebert
Copy link
Owner

mhuebert commented Jul 27, 2022 via email

@mtmr0x
Copy link

mtmr0x commented Jul 27, 2022

@mhuebert by any chance do you happen to have a working example? I'm not following very well the README.md. I'm relatively new to Clojure and it appears I'm missing something

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

3 participants