Skip to content

Commit e1b7f3f

Browse files
authored
Merge pull request #2464 from mroderick/imagemagick-check
Add ImageMagick requirement validation to db:seed
2 parents 2ef9f02 + f975359 commit e1b7f3f

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ Before you start, you will need to have Docker installed and running. You can [d
6868

6969
Run `bin/dup` to build and create the docker container. This will also set up the Rails application within the container and start the container. You will only have to run this command once. After initial setup, use `bin/dstart` to start an existing container - using `bin/dup` will recreate an existing container and reset the database.
7070

71+
**Note:** The Docker setup includes ImageMagick automatically. If you're using native installation, you must install ImageMagick separately (see [native-installation-instructions.md](./native-installation-instructions.md)).
72+
7173
### 4. Start the app
7274

7375
Run `bin/dserver` to start the Rails server.

db/seeds.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
if Rails.env.development?
2+
# Check for ImageMagick before seeding
3+
imagemagick_available = system('convert --version > /dev/null 2>&1') ||
4+
system('magick --version > /dev/null 2>&1')
5+
6+
unless imagemagick_available
7+
Rails.logger.error "=" * 80
8+
Rails.logger.error "ERROR: ImageMagick is required to run db:seed"
9+
Rails.logger.error "=" * 80
10+
Rails.logger.error ""
11+
Rails.logger.error "The seed task processes sponsor logo images, which requires ImageMagick."
12+
Rails.logger.error ""
13+
Rails.logger.error "Install ImageMagick:"
14+
Rails.logger.error " macOS: brew install imagemagick"
15+
Rails.logger.error " Ubuntu/Debian: apt-get install imagemagick"
16+
Rails.logger.error " Windows: https://imagemagick.org/script/download.php"
17+
Rails.logger.error ""
18+
Rails.logger.error "See native-installation-instructions.md for details."
19+
Rails.logger.error "=" * 80
20+
exit 1
21+
end
22+
223
begin
324
Rails.logger.info 'Running migrations...'
425
Rails.application.config.log_level = :info

native-installation-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ brew install postgresql
4747
brew services start postgresql
4848
```
4949

50-
Install other dependencies:
50+
Install required dependencies:
5151
```
5252
brew install imagemagick
5353
```

0 commit comments

Comments
 (0)