eexit / ghost-storage-cloudinary

:rocket: A fully-featured and deeply tested Cloudinary Ghost storage adapter
https://ghost.org/integrations/cloudinary/
81 stars 21 forks source link

"Unable to find storage adapter" in Ghost 4 / API compatibility issue? #126

Closed kevinstadler closed 2 years ago

kevinstadler commented 3 years ago

On a brand new Ghost 4 install using the same config.production.json that I'd used previously with 2.* and 3.0.3 I get the following error message:

Debug Information:
    OS: Fedora, v34
    Node Version: v14.17.0
    Ghost Version: 4.8.4
    Ghost-CLI Version: 1.17.3
    Environment: production
    Command: 'ghost start'
Message: Ghost was able to start, but errored during boot with: Unable to find storage adapter ghost-storage-cloudinary in ,/var/www/myurl.com/ghost/content/adapters/,/var/www/myurl.com/ghost/versions/4.8.4/core/server/adapters/.
Stack: Error: Ghost was able to start, but errored during boot with: Unable to find storage adapter ghost-storage-cloudinary in ,/var/www/myurl.com/ghost/content/adapters/,/var/www/myurl.com/ghost/versions/4.8.4/core/server/adapters/.
    at ChildProcess.<anonymous> (/home/kevin/ghost-cli/node_modules/ghost-cli/lib/utils/local-process.js:75:35)
    at ChildProcess.emit (events.js:376:20)
    at emit (internal/child_process.js:910:12)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)

I've tried putting the adapter in both /var/www/myurl.com/ghost/content/adapters/ and /var/www/myurl.com/ghost/versions/4.8.4/core/server/adapters/, directly in that path as well as the storage/ subdirectory, I've triple-checked the permissions of all files, but I simply can't get the storage adapter to load.

In the Ghost forum I found this suggestion https://forum.ghost.org/t/updating-from-3-20-3-to-latest-cloudinary-content-store/16699/2 that it might have to do with the adapter crashing because it uses internal API/exports that have become unavailable with Ghost 4? So following https://github.com/KINGMJ/qn-store/commit/bde0b56d5785b4a2f7b31c02c052cf71d932cc90 I tried removing all usage of the require('ghost-ignition').debug('adapter') as well as GhostError instances from the code but it still produces the same error message.

All help/hints would be appreciated. I'm also curious/confused about how @adikari apparently managed to get the adapter to start in #123?

PiotrKrzyzek commented 2 years ago

I have the same issue :(

I tried installing it the regular yarn way, putting it into my /adapters/storage/ folder and it says it can't find it.

eexit commented 2 years ago

Hello,

I've just released a new version. Do you still experience the issue?

Thanks!

Czer0C commented 2 years ago

I've run into this issue as I upgraded Ghost from 4.16 to a newer version near the end of 2021 and it turned out that the folder structure for some of the storage adapters has been re-organized, the reason being the release of the files and media upload feature which is kinda different from the regular image upload. So in short what you need to do is adjust the Ghost config file a little bit by specifying which adapter is used for which type of upload. This is my config after the update:

"storage": {
    "active": "ghost-storage-cloudinary",
    "media": "LocalMediaStorage",
    "files": "LocalFilesStorage",

    "ghost-storage-cloudinary" : {
        ...whatever
    }

}

For more reference, you can visit here: https://forum.ghost.org/t/error-update-to-4-22-0-from-4-21-0/26685/4

PiotrKrzyzek commented 2 years ago

I downloaded the release and placed it into adapters/storage/ and still the same issue in the latest Ghost:


Unable to find storage adapter ghost-storage-cloudinary in ,/var/lib/ghost/content/adapters/,/var/lib/ghost/versions/4.32.2/core/server/adapters/.

Error ID:

    1ea77c10-757c-11ec-8af8-b310e64f6215

----------------------------------------

IncorrectUsageError: Unable to find storage adapter ghost-storage-cloudinary in ,/var/lib/ghost/content/adapters/,/var/lib/ghost/versions/4.32.2/core/server/adapters/.

    at AdapterManager.getAdapter (/var/lib/ghost/versions/4.32.2/node_modules/@tryghost/adapter-manager/lib/AdapterManager.js:110:19)

    at Object.getAdapter (/var/lib/ghost/versions/4.32.2/core/server/services/adapter-manager/index.js:30:31)

    at Object.getStorage (/var/lib/ghost/versions/4.32.2/core/server/adapters/storage/index.js:14:27)

    at setupSiteApp (/var/lib/ghost/versions/4.32.2/core/frontend/web/site.js:118:71)

    at module.exports (/var/lib/ghost/versions/4.32.2/core/server/web/parent/frontend.js:22:58)

    at initExpressApps (/var/lib/ghost/versions/4.32.2/core/boot.js:187:68)

    at bootGhost (/var/lib/ghost/versions/4.32.2/core/boot.js:396:32)

/var/lib/ghost/content is a mounted directory (via docker) ... thus in the container the folders exist and are accessible:

/var/lib/ghost/content/adapters/storage/ghost-storage-cloudinary

Unless there's some Ghost setting in docker I'm missing, I dunno why it wouldn't work. If there some additional info I can provide, I'd be happy to do so.

eexit commented 2 years ago

Hello,

Have you tried not to mount the directory? 😉

Thanks.

PiotrKrzyzek commented 2 years ago

Hey there. So I haven't figured out the issue with my previous install in docker, BUT ....

I decided to toss docker out for GhostCMS, and then install this plugin (adapter) to a 'normal' (non docker) install of GhostCMS and that works 100%.

So, it seems the issue is not this but how GhostCMS docker handles ... well, many things :D

kevinstadler commented 2 years ago

I don't use Docker, so my original report was about a fresh local Ghost install, and it's still not working even with the latest adapter release, and even if I change the storage type in the json config.

@PiotrKrzyzek which version of Ghost and which release of the adapter are you using?

PiotrKrzyzek commented 2 years ago

Kevin: I'm using whatever gets installed when installing it the normal way. For me, when I did it this weekend: I have version 4.36.0 and the adapter version is the latest release (https://github.com/eexit/ghost-storage-cloudinary/releases/tag/v2.2.0).

daviareias commented 2 years ago

This is quite easy to solve, once I found the solution. You just have to change the folder, I just tested it here and was able to upload the file I wanted to Cloudinary.

Make sure you select the Programmable Media plan and put your cloud name and api keys in the file.

FROM ghost:4-alpine as cloudinary
WORKDIR $GHOST_INSTALL/current
RUN su-exec node yarn add ghost-storage-cloudinary

FROM ghost:4-alpine
COPY --chown=node:node --from=cloudinary $GHOST_INSTALL/current/node_modules /node_modules
COPY --chown=node:node --from=cloudinary $GHOST_INSTALL/current/node_modules/ghost-storage-cloudinary /var/lib/ghost/content/adapters/storage/ghost-storage-cloudinary

RUN set -ex; \
    #storage
    su-exec node ghost config storage.active ghost-storage-cloudinary; \
    #useDatedFolder
    su-exec node ghost config storage.ghost-storage-cloudinary.useDatedFolder false;\
    # auth
    su-exec node ghost config storage.ghost-storage-cloudinary.auth.cloud_name YOURCLOUDNAME;\
    su-exec node ghost config storage.ghost-storage-cloudinary.auth.api_key YOURAPIKEY;\
    su-exec node ghost config storage.ghost-storage-cloudinary.auth.api_secret YOURAPISECRET;\
    #upload
    su-exec node ghost config storage.ghost-storage-cloudinary.upload.folder blog-images; \
    su-exec node ghost config storage.ghost-storage-cloudinary.upload.tags ["blog"]; \
    su-exec node ghost config storage.ghost-storage-cloudinary.upload.use_filename true; \
    su-exec node ghost config storage.ghost-storage-cloudinary.upload.unique_filename false; \
    su-exec node ghost config storage.ghost-storage-cloudinary.upload.overwrite false; \
    # fetch
    su-exec node ghost config storage.ghost-storage-cloudinary.fetch.secure false; \
    su-exec node ghost config storage.ghost-storage-cloudinary.fetch.quality auto; \
    su-exec node ghost config storage.ghost-storage-cloudinary.fetch.cdn_subdomain true;\
    #imageOptiomization
    su-exec node ghost config storage.ghost-storage-cloudinary.imageOptimization.resize false;
eexit commented 2 years ago

Thanks for your help @daviareias!