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

Can't build with nlohmann/json installed without -DJSON_MultipleHeaders=ON #14438

Closed
kou opened this issue Jul 5, 2024 · 2 comments · Fixed by #14439
Closed

Can't build with nlohmann/json installed without -DJSON_MultipleHeaders=ON #14438

kou opened this issue Jul 5, 2024 · 2 comments · Fixed by #14439
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@kou
Copy link
Contributor

kou commented Jul 5, 2024

Does this issue affect the google-cloud-cpp project? If the problem is with
the Google Cloud service exposed by the google-cloud-cpp libraries instead of
the client libraries themselves, you may consider opening a support request
instead. The google-cloud-cpp developers cannot help you troubleshoot problems
with the service itself.

Yes.

What component of google-cloud-cpp is this related to? For example, is
this related to bigtable (i.e., something in google/cloud/bigtable), or GCS
(i.e., something in google/cloud/storage)?

google/cloud/internal/oauth2_universe_domain.h

Describe the bug A clear and concise description of what the bug is.

#include <nlohmann/json_fwd.hpp>
uses nlohmann/json_fwd.hpp not nlohmann/json.hpp but json_fwd.hpp is available only when nlohmann/json is installed with -DJSON_MultipleHeaders=ON.

https://github.com/nlohmann/json?tab=readme-ov-file#integration

You can further use file include/nlohmann/json_fwd.hpp for forward-declarations. The installation of json_fwd.hpp (as part of cmake's install step), can be achieved by setting -DJSON_MultipleHeaders=ON.

nlohmann/json provided by EPEL for RHEL 8 family doesn't provide json_fwd.hpp: https://packages.fedoraproject.org/pkgs/json/json-devel/epel-8.html#files

So we can't use the json-devel package on AlmaLinux 8. Here is an error log in apache/arrow:

https://github.com/ursacomputing/crossbow/actions/runs/9804176444/job/27071504390#step:8:3180

-- stderr output is:
In file included from /root/rpmbuild/BUILD/apache-arrow-17.0.0.dev465/cpp/build/google_cloud_cpp_ep-prefix/src/google_cloud_cpp_ep/google/cloud/internal/oauth2_authorized_user_credentials.cc:16:
/root/rpmbuild/BUILD/apache-arrow-17.0.0.dev465/cpp/build/google_cloud_cpp_ep-prefix/src/google_cloud_cpp_ep/google/cloud/internal/oauth2_universe_domain.h:22:10: fatal error: nlohmann/json_fwd.hpp: No such file or directory
 #include <nlohmann/json_fwd.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

To Reproduce Steps to reproduce the behavior:

  1. Prepare RHEL 8 based distribution such as AlmaLinux 8
  2. Prepare EPEL by sudo dnf install -y epel-release or something
  3. Install nlohmann/json by sudo dnf install -y json-devel
  4. Build
  5. See error

Expected behavior A clear and concise description of what you expected to
happen.

google-cloud-cpp can be built with nlohmann/json installed without -DJSON_MultipleHeaders=ON.

Operating system: If you are using a Linux distribution please include the
name and version of the distribution too.

AlmaLinux 8.

What compiler and version are you using? Please include the output of
g++ -v or clang++ -v or the equivalent command-line flag.

https://github.com/ursacomputing/crossbow/actions/runs/9804176444/job/27071504390#step:8:1579

-- The C compiler identification is GNU 8.5.0
-- The CXX compiler identification is GNU 8.5.0

What version of google-cloud-cpp are you using? Please include the output
from git rev-parse HEAD if you are compiling from source, or the version
number from the applicable google/cloud/*/version.h file.

https://github.com/googleapis/google-cloud-cpp/releases/tag/v2.22.0

Additional context Add any other context about the problem here.

Can we use nlohmann/json.h instead for portability?

diff --git a/google/cloud/internal/oauth2_universe_domain.h b/google/cloud/internal/oauth2_universe_domain.h
index e74e438a0d..ca0fc6aaf8 100644
--- a/google/cloud/internal/oauth2_universe_domain.h
+++ b/google/cloud/internal/oauth2_universe_domain.h
@@ -19,7 +19,7 @@
 #include "google/cloud/status.h"
 #include "google/cloud/status_or.h"
 #include "google/cloud/version.h"
-#include <nlohmann/json_fwd.hpp>
+#include <nlohmann/json.hpp>
 #include <string>
 
 namespace google {
@kou kou added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jul 5, 2024
kou added a commit to kou/arrow that referenced this issue Jul 6, 2024
…CentOS Stream 8

Because json-devel on them don't provide nlohmann/json_fwd.h that is
required by google-cloud-cpp.

The upstream issue:
googleapis/google-cloud-cpp#14438
kou added a commit to apache/arrow that referenced this issue Jul 6, 2024
… Stream 8 (#43159)

### Rationale for this change

Because json-devel on them don't provide nlohmann/json_fwd.h that is required by google-cloud-cpp.

The upstream issue:
googleapis/google-cloud-cpp#14438

### What changes are included in this PR?

Use bundled nlohmann/json instead.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* GitHub Issue: #43158

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@coryan coryan self-assigned this Jul 6, 2024
@coryan
Copy link
Contributor

coryan commented Jul 6, 2024

Thanks for this detailed bug report. As you probably noticed we merged a PR earlier today. FWIW, we stopped testing on RHEL 8 (and its brethren, such as AlmaLinux or RockyLinux). Happy to accept bug reports and suggested fixes like this one.

@kou
Copy link
Contributor Author

kou commented Jul 6, 2024

Thanks!

raulcd pushed a commit to apache/arrow that referenced this issue Jul 8, 2024
… Stream 8 (#43159)

### Rationale for this change

Because json-devel on them don't provide nlohmann/json_fwd.h that is required by google-cloud-cpp.

The upstream issue:
googleapis/google-cloud-cpp#14438

### What changes are included in this PR?

Use bundled nlohmann/json instead.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* GitHub Issue: #43158

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
zanmato1984 pushed a commit to zanmato1984/arrow that referenced this issue Jul 9, 2024
…CentOS Stream 8 (apache#43159)

### Rationale for this change

Because json-devel on them don't provide nlohmann/json_fwd.h that is required by google-cloud-cpp.

The upstream issue:
googleapis/google-cloud-cpp#14438

### What changes are included in this PR?

Use bundled nlohmann/json instead.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* GitHub Issue: apache#43158

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants