@@ -102,12 +102,16 @@ on selected paths.
102
102
103
103
## Loading of Code From Archive Files
104
104
105
- > #### Warning {: .warning }
105
+ > #### Change {: .info }
106
+ >
107
+ > The existing experimental support for archive files will be changed
108
+ > in a future release. As of Erlang/OTP 27, the function `code:lib_dir/2`,
109
+ > the `-code_path_choice` flag, and using `m:erl_prim_loader` for
110
+ > reading files from an archive are deprecated.
106
111
>
107
- > The support for loading code from archive files is experimental. The purpose
108
- > of releasing it before it is ready is to obtain early feedback. The file
109
- > format, semantics, interfaces, and so on, can be changed in a future release.
110
- > The function `lib_dir/2` and flag `-code_path_choice` are also experimental.
112
+ > `escript` scripts that use archive files should use
113
+ > `escript:extract/2` to read data files from its archive instead of using
114
+ > `code:lib_dir/2` and `m:erl_prim_loader`.
111
115
112
116
The Erlang archives are `ZIP` files with extension `.ez`. Erlang archives can
113
117
also be [enclosed in `escript`](`m:escript`) files whose file extension is arbitrary.
@@ -167,9 +171,9 @@ directory resolution update).
167
171
For each directory on the second level in the application archive (`ebin`,
168
172
`priv`, `src`, and so on), the code server first chooses the regular directory
169
173
if it exists and second from the archive. Function `code:lib_dir/2` returns the
170
- path to the subdirectory. For example, `code:lib_dir(megaco,ebin)` can return
174
+ path to the subdirectory. For example, `code:lib_dir(megaco, ebin)` can return
171
175
`/otp/root/lib/megaco-3.9.1.1.ez/megaco-3.9.1.1/ebin` while
172
- `code:lib_dir(megaco,priv)` can return `/otp/root/lib/megaco-3.9.1.1/priv`.
176
+ `code:lib_dir(megaco, priv)` can return `/otp/root/lib/megaco-3.9.1.1/priv`.
173
177
174
178
When an `escript` file contains an archive, there are no restrictions on the
175
179
name of the `escript` and no restrictions on how many applications that can be
@@ -178,9 +182,13 @@ level in the archive. At startup, the top directory in the embedded archive and
178
182
all (second level) `ebin` directories in the embedded archive are added to the
179
183
code path. See [`erts:escript(1)`](`e:erts:escript_cmd.md`).
180
184
181
- When the choice of directories in the code path is `strict`, the directory that
182
- ends up in the code path is exactly the stated one. This means that if, for
183
- example, the directory `$OTPROOT/lib/mnesia-4.4.7/ebin` is explicitly added to
185
+ A future-proof way for `escript` scripts to read data files from the archive is
186
+ to use the `escript:extract/2` function.
187
+
188
+ When the choice of directories in the code path is `strict` (which is
189
+ the default as of Erlang/OTP 27), the directory that ends up in the
190
+ code path is exactly the stated one. This means that if, for example,
191
+ the directory `$OTPROOT/lib/mnesia-4.4.7/ebin` is explicitly added to
184
192
the code path, the code server does not load files from
185
193
`$OTPROOT/lib/mnesia-4.4.7.ez/mnesia-4.4.7/ebin`.
186
194
@@ -322,6 +330,8 @@ common reasons.
322
330
-removed ({rehash ,0 ," the code path cache feature has been removed" }).
323
331
-removed ({is_module_native ,1 ," HiPE has been removed" }).
324
332
333
+ -deprecated ([{lib_dir ,2 ," this functionality will be removed in a future release" }]).
334
+
325
335
-export_type ([load_error_rsn / 0 , load_ret / 0 ]).
326
336
-export_type ([prepared_code / 0 ]).
327
337
-export_type ([module_status / 0 ]).
@@ -787,17 +797,23 @@ Returns `{error, bad_name}` if `Name` is not the name of an application under
787
797
lib_dir (App ) when is_atom (App ) ; is_list (App ) -> call ({dir ,{lib_dir ,App }}).
788
798
789
799
- doc """
800
+ > #### Change {: .info }
801
+ >
802
+ > This function is deprecated and will be removed in a future release.
803
+
790
804
Returns the path to a subdirectory directly under the top directory of an
791
805
application. Normally the subdirectories reside under the top directory for the
792
806
application, but when applications at least partly reside in an archive, the
793
807
situation is different. Some of the subdirectories can reside as regular
794
808
directories while others reside in an archive file. It is not checked whether
795
809
this directory exists.
796
810
811
+ Instead of using this function, use [`code:lib_dir/1`](`code:lib_dir/1`).
812
+
797
813
_Example:_
798
814
799
815
```text
800
- > code:lib_dir(megaco, priv).
816
+ > filename:join( code:lib_dir(megaco), " priv" ).
801
817
"/usr/local/otp/lib/megaco-3.9.1.1/priv"
802
818
```
803
819
0 commit comments