@@ -11,7 +11,7 @@ import Control.Monad.Logger
11
11
import Control.Monad.Reader
12
12
import Control.Monad.Trans.Control (MonadBaseControl )
13
13
import qualified Data.Aeson as A
14
- import Data.ByteString.Lazy.Char8 as BL
14
+ import Data.ByteString.Lazy.Char8 as BL8
15
15
import qualified Data.List as L
16
16
import Data.Map (Map )
17
17
import qualified Data.Map as M
@@ -28,8 +28,6 @@ import TestLib.Util
28
28
import UnliftIO.Directory
29
29
import UnliftIO.Process
30
30
31
- -- import qualified Data.ByteString.Lazy.Char8 as BL8
32
-
33
31
34
32
introduceJupyterRunner :: (
35
33
HasBaseContext context , MonadIO m , MonadMask m , MonadUnliftIO m , MonadBaseControl IO m
@@ -221,7 +219,7 @@ runKernelCode kernel code cb = do
221
219
Just _ -> (innerRunDir </> )
222
220
Nothing -> (outerRunDir </> )
223
221
224
- liftIO $ BL .writeFile (relativeToOuterRunDir notebook) (A. encode (notebookWithCode kernel code))
222
+ liftIO $ BL8 .writeFile (relativeToOuterRunDir notebook) (A. encode (notebookWithCode kernel code))
225
223
226
224
let papermillArgs = [
227
225
" notebook.ipynb" , " out.ipynb"
@@ -235,25 +233,27 @@ runKernelCode kernel code cb = do
235
233
236
234
cp <- case maybeBwrap of
237
235
Just bwrap -> do
236
+ -- Provide some core utils on the PATH. For example, the R kernel needs this:
238
237
-- https://github.com/codedownio/codedown-languages/issues/63
239
- -- binPathsJson <- readCreateProcessWithLogging (
240
- -- proc "nix" ["build"
241
- -- , "--impure"
242
- -- , "--expr", [i|with import <nixpkgs> {}; symlinkJoin { name = "base-paths"; paths = [which coreutils]; }|]
243
- -- , "--json"
244
- -- ]) ""
245
- -- binPaths <- case parseNixBuildJson <$> (A.eitherDecode (BL8.pack binPathsJson)) of
246
- -- Left err -> expectationFailure [i|Failed to parse bin paths: #{err}. JSON: #{binPathsJson}|]
247
- -- Right Nothing -> expectationFailure [i|Didn't find Nix output in: #{binPathsJson}|]
248
- -- Right (Just output) -> pure $ T.unpack output
249
- -- info [i|PATH: #{binPaths </> "bin"}|]
238
+ binDirJson <- readCreateProcessWithLogging (
239
+ proc " nix" [" build"
240
+ , " --impure"
241
+ , " --expr" , [i |with import <nixpkgs> {}; pkgsStatic.busybox|]
242
+ , " --json"
243
+ , " --no-link"
244
+ ]) " "
245
+ binDir <- case parseNixBuildJson <$> (A. eitherDecode (BL8. pack binDirJson)) of
246
+ Left err -> expectationFailure [i |Failed to parse bin paths: #{err}. JSON: #{binDirJson}|]
247
+ Right Nothing -> expectationFailure [i |Didn't find Nix output in: #{binDirJson}|]
248
+ Right (Just output) -> pure ((T. unpack output) </> " bin" )
249
+ info [i |PATH: #{binDir </> "bin"}|]
250
250
251
251
-- Get the full closure of the Nix environment and jupyter runner
252
252
fullClosure <- (Prelude. filter (/= " " ) . T. splitOn " \n " . T. pack) <$> readCreateProcessWithLogging (
253
253
proc " nix" ([" path-info" , " -r"
254
254
, jr
255
255
, nixEnv
256
- -- , binPaths
256
+ , binDir
257
257
])
258
258
) " "
259
259
@@ -265,7 +265,8 @@ runKernelCode kernel code cb = do
265
265
, " --setenv" , " JUPYTER_PATH" , jupyterPath
266
266
, " --chdir" , innerRunDir
267
267
268
- -- , "--setenv", "PATH", binPaths </> "bin"
268
+ , " --ro-bind" , binDir, " /bin"
269
+ , " --setenv" , " PATH" , " /bin"
269
270
270
271
, " --proc" , " /proc"
271
272
, " --dev" , " /dev"
0 commit comments